php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #28243 strange parse error
Submitted: 2004-05-01 16:39 UTC Modified: 2004-05-01 16:42 UTC
From: esflightsim at hotmail dot com Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 5.0.0RC2 OS: Linux
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: esflightsim at hotmail dot com
New email:
PHP Version: OS:

 

 [2004-05-01 16:39 UTC] esflightsim at hotmail dot com
Description:
------------
When I use isset() with a constant, it returns a strange
parse error

Reproduce code:
---------------
<?php
// No direct access
if(isset(MAIN_PAGE))
{


Expected result:
----------------
Parse error: parse error, unexpected 'T_CONSTANT' expecting T_VAR in /home/eirik/public_html/fspage/include1.php on line 3

Actual result:
--------------
Parse error: parse error, unexpected ')', expecting T_PAAMAYIM_NEKUDOTAYIM in /home/eirik/public_html/fspage/include1.php on line 3

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-05-01 16:42 UTC] gschlossnagle@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

From the manual:

isset?--?Determine whether a variable is set

 [2004-07-16 10:26 UTC] s dot pfalz at teles dot de
Well you are right that this is wrong usage of isset(), but looking at the behavour I would say that this is wrong, PHP 4 reports the correct error like this:

PHP Parse error:  parse error, expecting `T_VARIABLE' or `'$'' in /home/siegel/php_tests.php on line 6

But with PHP 5.0.0 you will get now:

Parse error: parse error, unexpected ')', expecting T_PAAMAYIM_NEKUDOTAYIM in /html/php_tests.php on line 6

which is in turn a complete wrong error message! 

here's the code that produces this (I know that it is wrong to isset() a constant, but PHP shouldn't answer with such a error message IMO). Even when one makes errors the interpreter should give accurate responses.

---[SNIP]---

define(SOME_VALUE   ,2);

if(!isset(SOME_VALUE)) echo("Not found");
else echo("found");

---[SNAP]----
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Sep 19 21:01:26 2024 UTC