object probleme

This is a discussion on object probleme within the PHP Language forums, part of the PHP Programming Forums category; I've created an instance of a class $smarty = new smarty(); then I create an other instance of an other ...


Go Back   Usenet Forums > PHP Programming Forums > PHP Language

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 10-16-2003
Geiregat Jonas
 
Posts: n/a
Default 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($smartyInstance){
$smarty = $smartyInstance;
// but when I do
$smarty->method("some parameters");
// it doesn't work
// how fix it ?
}
}

Reply With Quote
  #2 (permalink)  
Old 10-16-2003
Tom Thackrey
 
Posts: n/a
Default Re: object probleme


On 16-Oct-2003, Geiregat Jonas <eniac@sdf-eu.org> wrote:

> 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($smartyInstance){
> $smarty = $smartyInstance;
> // but when I do
> $smarty->method("some parameters");
> // it doesn't work
> // how fix it ?
> }
> }


$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($smartyInstance){
$this->smarty = $smartyInstance;
$this->smarty->method("some parameters");
}
}




--
Tom Thackrey
www.creative-light.com
tom (at) creative (dash) light (dot) com
do NOT send email to jamesbutler@willglen.net (it's reserved for spammers)
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 06:42 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0