Php - Access global variable inside class, Php global variable
Access global variable inside class
PHP global variable access inside the class
<?php
define('MYCONST', 'varname');
$varname = array("This is varname", "and array?");
class Myclass {
public $classvar;
function Myclass() {
$this->classvar =& $GLOBALS[MYCONST];
}
function printvar() {
echo $this->classvar[0];
echo $this->classvar[1];
}
};
$myobj = new Myclass;
$myobj->printvar();
?>
The topic on Php - Access global variable inside class is posted by - Math
Hope you have enjoyed, Php - Access global variable inside classThanks for your time