Define the class
class MyClass
{
public $PropertyA, $PropertyB, $PropertyC;
function MyFunctionName()
{
return "Value is $this->PropertyA.";
}
}
Use the class
$MyObject = new MyClass();
$MyObject->PropertyA = "abc";
echo $MyObject->MyFunctionName();
Constructor
The constructor function is optional, if defined it is automatically called when an object is instantiated.
class MyClass
{
public $PropertyA, $PropertyB, $PropertyC;
//*********************************
//********** CONSTRUCTOR **********
//*********************************
function __construct() //<<<You can optionally add arguments to be passed to this function when the class is created using new, e.g. function __construct($PropertyA, $PropertyB)
{
$this->PropertyA = "abc";
}
}
Feel free to comment if you can add help to this page or point out issues and solutions you have found. I do not provide support on this site, if you need help with a problem head over to stack overflow.