xxxxxxxxxx
<?php
class SimpleClass
{
public $var1 = 'hello';
}
?>
xxxxxxxxxx
class MyClass {
// Declare a class variable
public $myVariable;
// Constructor to initialize the variable
public function __construct() {
$this->myVariable = "Hello, world!";
}
// Method to display the value of the variable
public function displayVariable() {
echo $this->myVariable;
}
}
// Create an object of MyClass
$myObject = new MyClass();
// Call the method to display the variable value
$myObject->displayVariable();