Fatal error: Cannot use 'Object' as class name as it is reserved

17,361

Solution 1

"Object" is one of the reserved keyword of PHP. You can not use it as class name. Change the class name to resolve the error.

Solution 2

Use Php 7.1 version. It will solve that issue

Share:
17,361

Related videos on Youtube

ZUHDI
Author by

ZUHDI

Updated on May 25, 2022

Comments

  • ZUHDI
    ZUHDI almost 2 years

    Fatal error: Cannot use 'Object' as class name as it is reserved

    I'm trying to bake my project but it shows this error. I'm using cakephp 2.5.4 and PHP 7.0.32

    I tried to change the lib folder I used the lib folder for 2.8.0 and I tried to change PHP version to 5.6.38 but nothing worked. :(

    • MD. Jubair Mizan
      MD. Jubair Mizan over 5 years
      Please add your code that will be easy for understand what actually problem you happend
    • ArtisticPhoenix
      ArtisticPhoenix over 5 years
      That is true Class Object or Class true or any of the other "reserved" words don't work as class name. It's just part of the "deal"
    • ndm
      ndm over 5 years
      Note that you aren't actually using PHP 7.0.32 or 5.6.38, but PHP 7.2+, as Object is only a reservered name as of PHP 7.2. You're probably looking in the wrong place, hence whatever you're changing with regards to the PHP version has no effect. For CakePHP 2.x you need to use the latest 2.10 version for proper PHP 7.2 compatibility. stackoverflow.com/questions/52981403/…
    • Budi Mulyo
      Budi Mulyo almost 5 years
      almost same question, in different framework.. stackoverflow.com/questions/50269306/…
  • Halnex
    Halnex about 3 years
    7.1 didn't work for me but 5.6 did! Thanks!