Php class file how to access variables in other files I declare two files, one class file (123. class. php), a common file (index. php, the code is as follows), 123. class. how to obtain index in php. the value of $ abc in the PHP file (which is not included in the class file and cannot be obtained) 123. class. php code is as follows: PHPcode php class file how to access variables in other files
I declare two files, one class file (123. class. php), a common file (index. php, the code is as follows), 123. class. how to obtain index in php. $ abc value in the PHP file (the class file is not included directly and cannot be obtained)
123. the class. php code is as follows:
PHP code
Index. php code:
PHP code
Instantiation code:
$ Abc = new a123;
$ Abc-> index ();
------ Solution --------------------
Include ('index. php ');
Class a123 {
Public function index {
Global $ aa, $ bb; // or include ('index. php ');
Echo $ aa;
Echo $ bb;
}
}
------ Solution --------------------
Global