Welcome Guest, Not a member yet? Register   Sign In
i am good in php and bad in classes ( simple question )
#1

[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 .
#2

[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();
#3

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

[eluser]danmontgomery[/eluser]
Nope.
#5

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




Theme © iAndrew 2016 - Forum software by © MyBB