Source of the problem, new company Debug.
The code in the program is roughly the following
Class Ci {private static $instance = NULL; Public $name = ' Hello '; public $load = null; Public Function __construct () {self:: $instance = & $this; $this->load = new Load; Mlog (self:: $instance, __line__);//other code .... $this->name = ' My name '; }public static function &getinstance () {return self:: $instance;} } class My extends ci{public function __construct () {parent::__construct (); $this->model = new model; }} class Model {public Function __construct () {$this->name = _get ();//Nullmlog ("Success, and model-> Name = {$this->name} ", __line__);} } class Load {public $name = ' I am Load class ';p ublic function GetName () {return $this->name;} } $CI =& get_instance (); Mlog ($CI->name); Hello//Mlog ($CI->load->getname ()); I am Load class Mlog ($CI, __line__); $CI = new My; Mlog ($CI, __line__); function _get () {//call static Variablesglobal $CI; Non-boject//return $CI->load->name (); 500return $CI->name; NOTICE} function &get_instance () {return ci::getinstance (); } function Mlog ($content, $line = __line__, $display = True) {$next _line = "<br/>"; if (php_sapi_name () = = = ' CLI ') {$init = '; $next _line = "\ n";} if ($display) {echo $init; echo "In line: $line". $next _line; Print_r ($content); echo $next _line;} }
I believe friends can see that this is part of the CI framework, and developers use the following code in helper for the encapsulation method
<?php $CI =& get_instance (); function Demo () { global $CI; return $CI->mehton; Notice //return $CI->class->method;//500 }
The server directly reported 500. Through my first part of the code and comments, it should be possible to draw the following conclusions: In the function scope of the global $ref is not to get the reference, the PHP manual is also described in the details, see. You can't do anything but be careful, learn the basics ^_^
Variable references in PHP & cannot be used in conjunction with global