Lodius2000 Posted November 8, 2008 Share Posted November 8, 2008 im working on learning oop through an online tutorial its talking about public, proected and private right now and i am getting an error that doenst match what the tutorial says i should be getting Fatal error: Cannot access private property person::$pinn_number in ... instead i am getting Parse error: parse error, expecting `T_OLD_FUNCTION' or `T_FUNCTION' or `T_VAR' or `'}'' in /Users/imaging/Desktop/oop/class_lib.php on line 10 heres my code class_lib.php <?php class person { var $name; public $height; protected $social_insurance; private $pinn_number; function __construct($persons_name) { $this->name = $persons_name; } function set_name($new_name) { $this->name = $new_name; } function get_name() { return $this->name; } } ?> index.php <?php include("class_lib.php"); $stefan = new person("Stefan Mischook"); echo "Stefan's full name: " . $stefan->get_name(); /* Since $pinn_number was declared private, this line of code will generate an error. Try it out! */ echo "Tell me private stuff: " . $stefan->pinn_number; ?> heres the tutorial but my code has been cut and pasted from there just to make sure i didnt have typo http://www.killerphp.com/tutorials/object-oriented-php/php-objects-page-3.php whats the problem thanks Link to comment https://forums.phpfreaks.com/topic/131867-solved-oop-newb-error-message/ Share on other sites More sharing options...
DarkWater Posted November 8, 2008 Share Posted November 8, 2008 Are you running PHP4 by any chance? Link to comment https://forums.phpfreaks.com/topic/131867-solved-oop-newb-error-message/#findComment-685055 Share on other sites More sharing options...
Lodius2000 Posted November 8, 2008 Author Share Posted November 8, 2008 depends what does mac os tiger ship with, in the mean time ima run php_info ... edit: shite, 4.4.7 Link to comment https://forums.phpfreaks.com/topic/131867-solved-oop-newb-error-message/#findComment-685057 Share on other sites More sharing options...
DarkWater Posted November 8, 2008 Share Posted November 8, 2008 Upgrade. Link to comment https://forums.phpfreaks.com/topic/131867-solved-oop-newb-error-message/#findComment-685059 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.