Welcome Guest, Not a member yet? Register   Sign In
Calling an instance of a class from itself.
#3

[eluser]Taff[/eluser]
Firstly, thanks for replying...

I basically would like to know how to call a class from itself with codeIgniter...
<?php

Code:
class MatchingNode{

    function MatchingNode($nodeId){
        echo "loaded ".$nodeId;
        $this -> fillChildrenNodes();
    }
    
    function outputSomething(){
        echo "I can be called";
    }
    
    function fillChildrenNodes(){
    //Pseudo array
        $tmp = array(101,123,126,129);
        for($i = 0;$i <= 4;$i++){
            $A1 = &get;_instance();
            $param = $tmp[$i];
            $A1->load->library("MatchingNode",$param);
            //Call a method
            $A1->matchingnode->outputSomething();
        }
}

?&gt;

This is a pseudo code example, but doesn't work, I would like to know how to do something like (similar code without codeigniter):

Code:
class MatchingNode{

    function MatchingNode($nodeId){
        echo "loaded ".$nodeId;
        $this -> fillChildrenNodes();
    }
    
    function outputSomething(){
        echo "I can be called";
    }
    
    function fillChildrenNodes(){
    //Pseudo array
        $tmp = array(101,123,126,129);
        for($i = 0;$i <= 4;$i++){
            $A1 = &get;_instance();
            $param = $tmp[$i];
            $fubar = new MatchingNode($param);
            //Call a method
            $fubar->outputSomething();
        }
}

?&gt;

Cheers,
Taff


Messages In This Thread
Calling an instance of a class from itself. - by El Forum - 07-31-2008, 05:26 AM
Calling an instance of a class from itself. - by El Forum - 07-31-2008, 05:30 AM
Calling an instance of a class from itself. - by El Forum - 07-31-2008, 06:36 AM
Calling an instance of a class from itself. - by El Forum - 07-31-2008, 06:57 AM
Calling an instance of a class from itself. - by El Forum - 07-31-2008, 07:42 AM
Calling an instance of a class from itself. - by El Forum - 07-31-2008, 07:46 AM
Calling an instance of a class from itself. - by El Forum - 07-31-2008, 07:55 AM
Calling an instance of a class from itself. - by El Forum - 07-31-2008, 09:03 AM



Theme © iAndrew 2016 - Forum software by © MyBB