cgm225 Posted June 3, 2008 Share Posted June 3, 2008 Below I have created a snippet of code to pose a problem I am having with the getLimit() method. Basically, I want to instantiate the class as shown below, and expect it to output the number "100" but instead there is no output. I know that the value 100 is making it to the setNumberDisplayed, setPageLimits, and setLimit methods, but then I end up with an empty $this->limit in the getLimit() method, so nothing is returned. What am I doing wrong such that the getLimit() method is not returning "100"? <?php class Example { public function setNumberDisplayed($number) { $this->numberDisplayed = $number; } public function setPageLimit() { $this->setPageLimit = $this->numberDisplayed; $this->setLimit($this->setPageLimit); } public function setLimit($limit) { $this->limit = $limit; } public function getLimit() { return $this->limit; } } $example = new Example; $example->setNumberDisplayed(100); $example->setPageLimit(); echo $example->getLimit; ?> Link to comment https://forums.phpfreaks.com/topic/108462-class-instantiation-not-working-variable-returned-in-method-not-getting-value/ Share on other sites More sharing options...
PFMaBiSmAd Posted June 3, 2008 Share Posted June 3, 2008 echo $example->getLimit; should be - echo $example->getLimit(); When learning php, developing php code, or debugging php code, always turn on full php error reporting to get php to help you. The above problem causes a Notice error message. Link to comment https://forums.phpfreaks.com/topic/108462-class-instantiation-not-working-variable-returned-in-method-not-getting-value/#findComment-556144 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.