<?php
class Car
{
}
<?php
// Store the object in a variable and refer to the class
$car1 = new Car();
// To view the content of the object
var_dump($car1);
<?php
class Car
{
}
$car1 = new Car();
<?php
// Public access modifier
public $foo;
// Private access modifier
private $foo;
// Protected access modifier
protected $foo;
<?php
// Class declared with public access modifiers
class Car
{
public $brand;
// Parts will be stored in an array
public $parts = array();
public $continent = "Europe";
}
// Create new object
$car1 = new Car();
// Print on screen
echo $car1->continent;
// Visible in console
$car1->continent;
<?php
public function foobar()
{
return $this->foo . " is " . $this->bar;
}