gazever Posted November 26, 2009 Share Posted November 26, 2009 Hi what am I doing wrong here Just trying to learn and use classes class form{ var $variable1 = 'test string here'; function return_form(){ return $this->$variable1; } } $test = new form; $theform = $test->return_form(); echo $theform; Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted November 26, 2009 Share Posted November 26, 2009 There is an extra $ in the following line - return $this->$variable1; It should be - return $this->variable1; I'm assuming that you are developing and debugging php code on a system with error_reporting set to E_ALL and display_errors set to ON so that php will alert you to problems is finds (there would have been an error on the line posted above that would have helped you in finding the problem with that line of code.) Quote Link to comment Share on other sites More sharing options...
gazever Posted November 29, 2009 Author Share Posted November 29, 2009 Yes I have all errors on, what you pointed out was what I was missing, been coding normal PHP for a couple of years, now trying to include classes as part of my coding practices, more learning curves. Thanks for your help Quote Link to comment 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.