octaflop Posted May 15, 2008 Share Posted May 15, 2008 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; Link to comment https://forums.phpfreaks.com/topic/105811-solved-how-to-call-these-functions-really-basic-question/ Share on other sites More sharing options...
448191 Posted May 15, 2008 Share Posted May 15, 2008 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. Link to comment https://forums.phpfreaks.com/topic/105811-solved-how-to-call-these-functions-really-basic-question/#findComment-542336 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.