CodeIgniter Forums
non-object Error - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: non-object Error (/showthread.php?tid=67581)



non-object Error - UygarDemirKoç - 03-12-2017

Hi,
I'm new on the forum and I don't know I'm writing in correct place Smile
I passed Ubuntu yesterday and my Codeigniter projects give a lot of errors. (I'm using PHP 5.5.6) I clean some of that but I'm getting an error and I can't clean it. (It's on the attachment) Can you help me? Thanks...


RE: non-object Error - InsiteFX - 03-12-2017

The CodeIgniter recommends PHP version 5.6 or above.

Try upgrading your PHP version.

I'am running PHP version 7.1.1


RE: non-object Error - Narf - 03-12-2017

(03-12-2017, 04:00 AM)InsiteFX Wrote: The CodeIgniter recommends PHP version 5.6 or above.

Try upgrading your PHP version.

I'am running PHP version 7.1.1

And while that is true, if you actually looked at the error you'd see it has nothing to do with the PHP version.


RE: non-object Error - pdthinh - 03-12-2017

(03-12-2017, 01:59 AM)UygarDemirKoç Wrote: Hi,
I'm new on the forum and I don't know I'm writing in correct place Smile
I passed Ubuntu yesterday and my Codeigniter projects give a lot of errors. (I'm using PHP 5.5.6) I clean some of that but I'm getting an error and I can't clean it. (It's on the attachment) Can you help me? Thanks...

Does your Start controller extend CI_Controller, e.g:
PHP Code:
class Start extends CI_Controller
{




RE: non-object Error - InsiteFX - 03-12-2017

Make sure that you have a constructor also.

PHP Code:
class Start extends CI_Controller
{

 
   public function __construct()
 
   {
 
       parent::__construct();
 
   }





RE: non-object Error - Narf - 03-12-2017

(03-12-2017, 09:28 AM)InsiteFX Wrote: Make sure that you have a constructor also.

PHP Code:
class Start extends CI_Controller
{

 
   public function __construct()
 
   {
 
       parent::__construct();
 
   }



A constructor that only calls its parent constructor is completely pointless.


RE: non-object Error - marksman - 03-12-2017

Maybe you are calling on a property that is not defined, you may be do some verification before calling a property something like
PHP Code:
property_exists(__CLASS__'propertyName'
and as a friendly advice if you have your own autoloader put it in your autoloader, your autoloader is the best location where you will have to define those properties and to be accessible by your class.
for example you have your MY_Autoloader that extends to you CI_Controller and your controller extends to MY_Autoloader or it depends how you name it. In this case the property has been set automatically before your controller has been loaded. Goodluck. Smile

Just take note, using $this and static are different instance.


RE: non-object Error - UygarDemirKoç - 03-19-2017

I tried to install PHP7 with Apache2. It's working right now. Thanks, the problem is solved Smile