CodeIgniter Forums

Full Version: non-object Error
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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...
The CodeIgniter recommends PHP version 5.6 or above.

Try upgrading your PHP version.

I'am running PHP version 7.1.1
(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.
(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
{

Make sure that you have a constructor also.

PHP Code:
class Start extends CI_Controller
{

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


(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.
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.
I tried to install PHP7 with Apache2. It's working right now. Thanks, the problem is solved Smile