php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #21942 array_intersect with empty in IF statement
Submitted: 2003-01-29 07:59 UTC Modified: 2012-06-20 19:14 UTC
From: verx at implix dot com Assigned: nikic (profile)
Status: Closed Package: *General Issues
PHP Version: 4.3.0 OS: Linux 2.4
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: verx at implix dot com
New email:
PHP Version: OS:

 

 [2003-01-29 07:59 UTC] verx at implix dot com
$array1 = array ("a" => "green", "red", "blue");
$array2 = array ("b" => "green", "yellow", "red");

if (false == empty(array_intersect ($array1, $array2)))
{
	echo 1;	
}

Log output:
PHP Parse error:  parse error, unexpected T_STRING, expecting T_VARIABLE or '$' in /var/www/test/arint.php on line 6

line 6 is the line with IF statement.

However the following code works perfectly:

$array1 = array ("a" => "green", "red", "blue");
$array2 = array ("b" => "green", "yellow", "red");
$result = array_intersect ($array1, $array2);

if (false == empty($result))
{
	echo 1;	
}

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-01-29 08:00 UTC] derick@php.net
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions. 

Thank you for your interest in PHP.

read the docs @ php.net/empty again.
 [2003-01-30 08:45 UTC] hholzgra@php.net
Feature Request: have a meaningful (not to 'us' but to 'them')  error message here ...
 [2012-06-20 19:14 UTC] nikic@php.net
Using empty() on function call results will be possible in PHP 5.5. For more info see https://wiki.php.net/rfc/empty_isset_exprs.
 [2012-06-20 19:14 UTC] nikic@php.net
-Status: Open +Status: Closed -Package: Feature/Change Request +Package: *General Issues -Assigned To: +Assigned To: nikic
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Fri Aug 15 18:00:02 2025 UTC