Q:

Class method not recognised in php in Yii

I have a simple model which adds 2 numbers which are gives as argument however it looks as if the build-in function add() is not getting recognised. 
Here is the model
    <?php

class SimpleMaths extends CModel{

    private $numberone;
    private $numbertwo;

    public function SimpleMaths($numberones,$numbertwos){
        $numberone = $numberones;
        $numbertwo = $numbertwos;

    }

    public function add()
    {
        return $numbertwo + $numberone;
    }

    public function attributeNames(){
        return array('number 1' => $numberone, 'number 2'=> $numbertwo);
    }
}

?>

Here is the controller:
    <?php

class BlogController extends Controller{

    public function actionIndex(){
        $none = $_GET['n1'];
        $ntwo = $_GET['n2'];
        $model = new SimpleMaths($ntwo,$none);
        // $sum = $model.add();
        $array = get_class_methods('SimpleMaths');

        $this->render("index",array("interesting"=>$array,"model"=>$model));
    }

}

?>

Here is the view
    <?php

echo "Hello World";
foreach($interesting as $one)
{
    echo $one."<br>";
    echo "<hr>";
    echo $model.add();
}

?>

The add function gets displayed as one of the functions however when called it simply hides itself?
Here is the error:
Fatal error: Call to undefined function add() in C:\wamp\www\testdrive\protected\views\blog\index.php on line 8

A:

in the code that you are showing, it's like you want to echo $model which is an Object, then append whatever function add() returns to it,
you need to change that to
echo $model->add();

