Jump to content

classes


gazever

Recommended Posts

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;

 

Link to comment
Share on other sites

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.)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.