CodeIgniter Forums
i am good in php and bad in classes ( simple question ) - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: i am good in php and bad in classes ( simple question ) (/thread-33433.html)



i am good in php and bad in classes ( simple question ) - El Forum - 08-25-2010

[eluser]Mr.CodeIgniter[/eluser]
if i have this class :
Code:
class test{
   function hellow(){
      echo"hellow world";
   }
}
$name = new test();
$name->hellow->test2();
i know function test2 not exist , but if i want create it and call it like example
at end line , where i can create it.
i hope to undersand me .


i am good in php and bad in classes ( simple question ) - El Forum - 08-25-2010

[eluser]danmontgomery[/eluser]
Code:
class Hello {
    function test2() {
        echo 'hello world';
    }
}

class Test {
    public $hellow;

    function test() {
        $this->hellow = new Hello();
    }
}

$name = new Test();
$name->hellow->test2();



i am good in php and bad in classes ( simple question ) - El Forum - 08-25-2010

[eluser]Mr.CodeIgniter[/eluser]
is have other ways or not ( just question )


i am good in php and bad in classes ( simple question ) - El Forum - 08-25-2010

[eluser]danmontgomery[/eluser]
Nope.


i am good in php and bad in classes ( simple question ) - El Forum - 08-25-2010

[eluser]CI_avatar[/eluser]
noctrum is right, its class extension to come up with $class->class->function();