object probleme

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Geiregat Jonas

    object probleme

    I've created an instance of a class
    $smarty = new smarty();
    then I create an other instance of an other class and sending the
    $smarty instance to that class
    $user = new user($smarty);
    This is the user class

    class user {
    var $smarty
    function user($smartyIns tance){
    $smarty = $smartyInstance ;
    // but when I do
    $smarty->method("some parameters");
    // it doesn't work
    // how fix it ?
    }
    }

  • Tom Thackrey

    #2
    Re: object probleme


    On 16-Oct-2003, Geiregat Jonas <eniac@sdf-eu.org> wrote:
    [color=blue]
    > I've created an instance of a class
    > $smarty = new smarty();
    > then I create an other instance of an other class and sending the
    > $smarty instance to that class
    > $user = new user($smarty);
    > This is the user class
    >
    > class user {
    > var $smarty
    > function user($smartyIns tance){
    > $smarty = $smartyInstance ;
    > // but when I do
    > $smarty->method("some parameters");
    > // it doesn't work
    > // how fix it ?
    > }
    > }[/color]

    $smarty is local to the function named user. If you want to refer to the
    class variable you need to use $this->smarty like:

    class user {
    var $smarty;
    function user($smartyIns tance){
    $this->smarty = $smartyInstance ;
    $this->smarty->method("some parameters");
    }
    }




    --
    Tom Thackrey

    tom (at) creative (dash) light (dot) com
    do NOT send email to jamesbutler@wil lglen.net (it's reserved for spammers)

    Comment

    Working...