php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #32151 empty($i++) not work correctly
Submitted: 2005-03-01 15:41 UTC Modified: 2005-03-01 15:47 UTC
From: konicekmartin at seznam dot cz Assigned:
Status: Not a bug Package: Variables related
PHP Version: 4.3.9 OS: Linux
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: konicekmartin at seznam dot cz
New email:
PHP Version: OS:

 

 [2005-03-01 15:41 UTC] konicekmartin at seznam dot cz
Description:
------------
I expect that $i=0; echo $empty($i++) return true instead of parse error

Reproduce code:
---------------
$i=0;
while($i<10){
if(empty($i++)){
echo 'firstline';
} else {
echo $i++;
}
}

Expected result:
----------------
Do the same as

$i=0;
while($i<10){
if($i++ == 0){
echo 'firstline';
} else {
echo $i++;
}
}

Actual result:
--------------
Parse error: parse error, expecting `')'' 

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-03-01 15:47 UTC] tony2001@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

"empty() only checks variables as anything else will result in a parse error. In otherwords, the following will not work: empty(addslashes($name))."

empty() doesn't work with expression, while $i++ is valid increment expression.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sun Jul 27 23:00:03 2025 UTC