本帖最后由 abu_sec 于 2013-05-24 17:07:31 编辑

解决方案 »

  1.   

    $this 对象自己比如你
    $c=new cal(); //实例化类cal,这时 $c 就是对象了
    echo "(2+3)*10= " .$c->result('2','3','10'); //你可以这样访问 $c 这个对象那么在 $c 内部你该如何访问呢?
    答案就是用 $this
      

  2.   

    $this->prt() 里面应该不能放。。
    在执行到$a*$c的时候会报错。。
    Unsupported operand types 
    意思是数组和数字不可相乘吧。
    $this 代表这个实例化的对象本身。
    这个对象里包括prt()方法。
     $this->prt()  意思就是执行这个对象本身包含的prt()
    ->大致就是 选取和执行的意思。
      

  3.   

    是吗?
    那这段代码你可以执行吗?我是报错的。
    可以运行的话麻烦告诉下我结果。<?php$a = array(1,2);
        class cal{
            public function sum($a,$b){
                return $a+$b;
            }
            public function prt($a,$c){
                return $a*$c;
            }
            public function result($a,$b,$c){
                $a=$this->sum($a,$b);
                return $this->prt($a,$c);
            }
        }
        $c=new cal();
        echo "(2+3)*10= " .$c->result($a,'3','10');?>
      

  4.   

    这段代码不能运行,但<?php 
        class cal{
            public function sum($a,$b){
                return $a+$b;
            }
            public function prt($a,$c){
                return $a*$c;
            }
            public function result($a,$b,$c){
                $a=$this->sum($a,$b);
                return $this->prt($a,$c);
            }
        }
        $c=new cal();
        echo "(2+3)*10= " .$c->result('2','3','10');
    ?>这段代码可以运行 我帖子的这段
      

  5.   

    那当然可以运行了。
    我心里的var mixed
      int     整型
      longint 长整型
      real    实数型
      char    字符型
      string  字符串
      array   数组
    不知道是不是我误解了LZ问的意思
      

  6.   

    哦没有,我理解错了 谢谢你的回答thanks!