jsimmons Posted December 30, 2007 Share Posted December 30, 2007 Running: Windows Server 2003 WAMP with Apache 2.0.55, MySQL 5.0.21 and PHP 5.14 I have the following code: <?php class TestClass { private $a; private $b; public function __construct() { $this->a = 0; $this->b = 0; } public function is_active() { return ($this->a == 1); } public function is_loaded() { return ($this->b == 1); } } $testX = new TestClass(); if ($testX->is_active() && $testX->is_loaded()) { // do something } ?> All of this code is in the same file, but I'm getting this error (occurring on the line with the "if" statement): Fatal error: Call to a member function is_loaded() on a non-object in filename.php on line 23. What am I doing wrong? Quote Link to comment https://forums.phpfreaks.com/topic/83707-objects-not-being-instantiated/ Share on other sites More sharing options...
tapos Posted December 30, 2007 Share Posted December 30, 2007 I think it's your php version problem. you coded at php5 but run the script in php4 Thanks -- Tapos Pal Quote Link to comment https://forums.phpfreaks.com/topic/83707-objects-not-being-instantiated/#findComment-425895 Share on other sites More sharing options...
tibberous Posted December 30, 2007 Share Posted December 30, 2007 It works for me - do a phpinfo() and make sure your running 5, because theres nothing wrong with the code. Quote Link to comment https://forums.phpfreaks.com/topic/83707-objects-not-being-instantiated/#findComment-425897 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.