codeigniter using function inside a controller
09:39 19 Oct 2012

For some reason I cant run the change() function and everything after it stops. I try with $this->change() but the effect is the same. If I run the function in a php file its working and the num is changing.

class Test extends CI_Controller {

    function __construct(){
        parent::__construct();
    }

    public function home(){

        $num = 1;

        change($num);


        function change($num,$rand=false){

            echo 'inside function'; // this is not shown

            if($num < 4) {
                $rand = rand(1,9);
                $num = $num.$rand;
                change($num,$rand);
            } else {
                echo $num;
            }
        }
        echo 'done'; // this is not shown

    }

}
php codeigniter function controller