WilliamNz Posted April 30, 2007 Share Posted April 30, 2007 Hi there I am on a quest to understand to an intermediate level, using classes / functions & inheritance. Heres what I have so far, this is echoing object#id1 instead of "TEVEEEZ!" class soccer { function roffle_lol($tevez) { $this->$tevez; return $tevez; } } $lol = "TEVEZZZ!"; $result = new soccer($lol); echo($result); I orginally wanted to call the function roffle_lol from outside the class, rather than call the whole class which seems to be what I am doing in the line " $result = new soccer($lol); ".... Any help appreciated Quote Link to comment https://forums.phpfreaks.com/topic/49382-trying-to-understand-functions-inheritance/ Share on other sites More sharing options...
MadTechie Posted April 30, 2007 Share Posted April 30, 2007 almost class soccer { function roffle_lol($tevez) { $this->$tevez; return $tevez; } } $lol = "TEVEZZZ!"; $soc = new soccer; $result = $soc->roffle_lol($lol) echo($result); Quote Link to comment https://forums.phpfreaks.com/topic/49382-trying-to-understand-functions-inheritance/#findComment-241988 Share on other sites More sharing options...
trq Posted May 1, 2007 Share Posted May 1, 2007 Not exactly sure what you want to achieve with your example.... <?php class soccer { private $tevez; function __construct($tevez) { $this->tevez = $tevez; } function roffle_lol() { return $this->tevez; } } $lol = "TEVEZZZ!"; $soc = new soccer($lol); $result = $soc->roffle_lol(); echo $result; ?> there is no inheritance covered in this (or any of the above) example, and they are called methods not functions when they appear within a class. Quote Link to comment https://forums.phpfreaks.com/topic/49382-trying-to-understand-functions-inheritance/#findComment-241992 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.