jsimmons Posted March 24, 2006 Share Posted March 24, 2006 I tried to add a function to a class and I get an error sayng the function isn't defined when I call the function from within the same class. The function is most certainly there. Is there something more to adding a function to a class than, ummm, adding it? Link to comment https://forums.phpfreaks.com/topic/5679-undefined-function/ Share on other sites More sharing options...
redbullmarky Posted March 24, 2006 Share Posted March 24, 2006 [!--quoteo(post=357889:date=Mar 24 2006, 11:34 AM:name=jsimmons)--][div class=\'quotetop\']QUOTE(jsimmons @ Mar 24 2006, 11:34 AM) [snapback]357889[/snapback][/div][div class=\'quotemain\'][!--quotec--]I tried to add a function to a class and I get an error sayng the function isn't defined when I call the function from within the same class. The function is most certainly there. Is there something more to adding a function to a class than, ummm, adding it?[/quote]are you referering to it properly? even tho it's in the same class, you still have to refer to it, for example ,like:[code]$this->myfunction();[/code][b]EDIT:[/b] to clear up, $this is used to referer to any of a classes objects from within, including variables. it doesnt matter what the class is called, you still use $this when refering to something from within.hope that works Link to comment https://forums.phpfreaks.com/topic/5679-undefined-function/#findComment-20233 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.