class Database {
protected $userName;
protected $password;
protected $dbName;
public function __construct ( $UserName, $Password, $DbName ) {
$this->userName = $UserName;
$this->password = $Password;
$this->dbName = $DbName;
}
}
// and you would use this as:
$db = new Database ( 'user_name', 'password', 'database_name' );
class Person {
public function __construct() {
// Code called for each new Person we create
}
}
$person = new Person();
class Person {
public $name = '';
public function __construct( $name ) {
$this->name = $name;
}
}
$person = new Person( "Joe" );
echo $person->name;
class Cat
{
function Cat()
{
echo 'meow';
}
}
class Cat
{
function __construct()
{
echo 'meow';
}
}
$cat = new Cat();
class Cat
{
function Cat()
{
echo 'meow';
}
}
class cat {
function speak() {
echo "meow";
}
}
include('class_cat.php');
mycat = new cat;
$speak = cat->speak();
echo $speak;