jjacquay712 Posted February 6, 2009 Share Posted February 6, 2009 I am learning php oop and am trying this code: <?php class person { function lol() { echo 'hey'; } public $name; public $height; public $weight; public $hair; } $object = new person; $object->name = "John"; $object->height = "'6\"0"; $object->weight = 190; $object->hair = "Brown"; echo "The new persons is: " . $object->name . " " . $object->height . " " . $object->weight . " " . $object->hair; ?> but it gives me this error: Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in *** on line 14 any ideas? Link to comment https://forums.phpfreaks.com/topic/144064-solved-php-class-problem/ Share on other sites More sharing options...
Mark Baker Posted February 6, 2009 Share Posted February 6, 2009 $object = new person(); Link to comment https://forums.phpfreaks.com/topic/144064-solved-php-class-problem/#findComment-755909 Share on other sites More sharing options...
jjacquay712 Posted February 6, 2009 Author Share Posted February 6, 2009 I found the problem, you declare properties with var, not public Link to comment https://forums.phpfreaks.com/topic/144064-solved-php-class-problem/#findComment-755910 Share on other sites More sharing options...
Mark Baker Posted February 6, 2009 Share Posted February 6, 2009 I found the problem, you declare properties with var, not publicPHP 4 uses var, PHP 5 uses private, protected or public Link to comment https://forums.phpfreaks.com/topic/144064-solved-php-class-problem/#findComment-755936 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.