第11月第21天 php引用

來源:互聯網
上載者:User

標籤:errors   ams   self   const   php   ret   bug   sage   require   

1.

class CI_Controller {    private static $instance;    /**     * Constructor     */    public function __construct()    {        self::$instance =& $this;        // Assign all the class objects that were instantiated by the        // bootstrap file (CodeIgniter.php) to local class variables        // so that CI can run as one big super object.        foreach (is_loaded() as $var => $class)        {            $this->$var =& load_class($class);        }        $this->load =& load_class(‘Loader‘, ‘core‘);        $this->load->initialize();                log_message(‘debug‘, "Controller Class Initialized");    }    public static function &get_instance()    {        return self::$instance;    }}...public function database($params = ‘‘, $return = FALSE, $active_record = NULL)    {        // Grab the super object        $CI =& get_instance();        // Do we even need to load the database class?        if (class_exists(‘CI_DB‘) AND $return == FALSE AND $active_record == NULL AND isset($CI->db) AND is_object($CI->db))        {            return FALSE;        }        require_once(BASEPATH.‘database/DB.php‘);        if ($return === TRUE)        {            return DB($params, $active_record);        }        // Initialize the db variable.  Needed to prevent        // reference errors with some configurations        $CI->db = ‘‘;        // Load the DB class        $CI->db =& DB($params, $active_record);    }

 

$a=test()方式調用函數,只是將函數的值賦給$a而已, 而$a做任何改變 都不會影響到函數中的$b
而通過$a=&test()方式調用函數呢, 他的作用是 將return $b中的 $b變數的記憶體位址與$a變數的記憶體位址 指向了同一個地方
即產生了相當於這樣的效果($a=&$b;) 所以改變$a的值 也同時改變了$b的值 所以在執行了
$a=&test();
$a=5;
以後,$b的值變為了5

 

http://www.cnblogs.com/xiaochaohuashengmi/archive/2011/09/10/2173092.html

 

第11月第21天 php引用

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.