Jump to content

[SOLVED] how to call these functions? Really basic question.


octaflop

Recommended Posts

Hey all. When I try the following code, I don't receive any output. var_dump only gives me 'NULL'.

Any ideas on where I'm going wrong?

 

class Person {
var $name;

function get_name(){
	return $this->name;
}
function set_name($new_name){
	$this->name = $new_name;
}
}

$a = new Person();
$a->set_name("George");
echo $a->get_name;

If you had E_NOTICE error reporting turned on, you would know.

 

get_name is method, you're calling it without parenthesis: php will think it needs to find a property and 'll raise a notice saying "Undefined property blablahblah"...

 

Always set error reporting to a minimum of E_ALL (preferably on E_STRICT on php5) when developing.

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.