谢谢老大,前段时间在php5下使用mambo就出现过问题,问题就在引用上。

解决方案 »

  1.   

    PHP5 对象的实例化默认是传址才对,不需要&
      

  2.   

    创建对象的拷贝使用clone关键字
      

  3.   

    1、"&"这种方式就是是"传址", 但由于内部数据结构的原因与c是有区别的,所以称其为“引用”
    2、php5的对象默认是传“引用”而不是"传值"。
    <?php
    class foo {
      var $v = 1;
      function show() {
        echo $this->v;
      }
    }$a = new foo;
    $b = $a;
    $a->show(); //out 1
    $a->v = 3;
    $b->show(); //out 3 for php5
    ?> 
    可见$a和$b是一个东西,而这个代码在php4中执行时$b->show(); 只会输出1
      

  4.   

    PHP 4 improved the situation. The new version introduced the notion of references, which allowed multiple symbols in PHP's symbol space to actually refer to the same place in memory. This means that you could have two or more names for the same variable, as shown in Listing 6.20.-----------------
    才找到的