<?php
// Target : Connecting to phpmyadmin thorugh oop way.
// Note : Try this in your local server. It works 100%.
Class Connect {
//oop var declaration
var $server = "localhost";
var $user = "root";
var $password = "";
var $dbc;
// function or method declaration.
function connectMySql(){
$dbc = new mysqli($this->server,$this->user,$this->password);
//Status of connection.
if($dbc->connect_error) {
die("Not Connected" .$dbc->connect_error);
}
else {
echo "Connected to server";
}
}//end of function connectMysql.
}// end of class connect.
//Object creation.
$x = new Connect();
//Accessing method.
$x->connectMysql();
?>
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.