![]() |
How to Set a Variable Value within a PHP ClassThe below script demonstrates how to set the value of a variable with a PHP class: *** Example Starts *** <?php class MyClass { //variable will be global inside the object public function getMyClassVariable() { //create an instance of the class as the $MyObject object //You access a class variable from outside the class using the arrow operator. The arrow tells php that the variable is part of the $mine object echo $MyObject->getMyClassVariable(); *** Example Ends *** The browser output of this script should be 10.
|
|
All Content ©2020 WebRef.eu |