3

I am using following code:

define ('EMPTY', 'test');
echo EMPTY;

But I am unable to get output. I am getting following Error:

Parse error: syntax error, unexpected ';', expecting '('
Maria
  • 35
  • 6
  • 1
    Maria, using an IDE, like PHPStorm or Netbeans, should give you real-time information on whether you are using a reserved word as well as many other enhancements designed to save you time. – Devon Bessemer Jan 02 '16 at 15:56

1 Answers1

3

Empty is a reserved word.

<?php

define ('EMPTY2', 'test');
echo EMPTY2;

Works as intended.

VolkerK
  • 95,432
  • 20
  • 163
  • 226
Niclas Larsson
  • 1,317
  • 8
  • 13
  • 1
    Thanks for quick response. How can we know that if some word is reserved or not? I checked the link you provided above. On that link it does not say that EMPTY is reserved word. – Maria Jan 02 '16 at 15:51
  • 2
    The documentation is located at http://php.net (here's the link: http://php.net/manual/en/reserved.php) – Niclas Larsson Jan 02 '16 at 15:54
  • Thanks for the useful link. I checked link but even in that link I did not find "EMPTY" as reserved. It has "empty()" as reserved but not "EMPTY". I did not find that anywhere. – Maria Jan 02 '16 at 15:59
  • All those are case insensitive. – Niclas Larsson Jan 02 '16 at 16:01
  • Yes I understand that but they have parentheses " empty() " not just "empty" or "EMPTY" – Maria Jan 02 '16 at 16:06
  • 1
    Ther're called "language constructs". Have a look here http://stackoverflow.com/questions/3254327/php-what-are-language-constructs-and-why-do-we-need-them – Niclas Larsson Jan 02 '16 at 16:13
  • 1
    @Maria: ...which is why PHP is complaining. You used the reserved word `empty` and then it's expecting `()`. – Lightness Races in Orbit Jan 02 '16 at 16:29