php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #33466 Arrays are not handles as Variables
Submitted: 2005-06-24 15:18 UTC Modified: 2005-06-24 15:37 UTC
From: clynx at succont dot de Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 5CVS-2005-06-24 (dev) OS: FreeBSD 4.10/FreeBSD 5.4/WinXP
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: clynx at succont dot de
New email:
PHP Version: OS:

 

 [2005-06-24 15:18 UTC] clynx at succont dot de
Description:
------------
When you try to use array_intersect in combination with a different Function, it leads to a strange Error Message.

The Reproduce Code give the Error while the following does not:
<?php
$array1 = array('foo', 'bar', 'test');
$array2 = array('foo', 'me' );
$result = array_intersect( $array1, $array2 );
var_dump( array_shift( $result ) );
?>

And as far as array_intersect retuns an Array (a Variable ;o) this Error is a little bit strange.

Reproduce code:
---------------
<?php
$array1 = array('foo', 'bar', 'test');
$array2 = array('foo', 'me' );
var_dump( array_shift( array_intersect( $array1, $array2 ) ) );
?>

Expected result:
----------------
webdev# php /htdocs/beta.webdev/succont.Unitized/test.php
string(3) "foo"

Actual result:
--------------
webdev# php /htdocs/beta.webdev/succont.Unitized/test.php
PHP Fatal error:  Only variables can be passed by reference in /usr/local/htdocs/beta.webdev/succont.Unitized/test.php on line 4

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-06-24 15:22 UTC] tony2001@php.net
array_shift() accepts only variables passed by reference.
Obviously an expression result is not a variable.
 [2005-06-24 15:34 UTC] clynx at succont dot de
But array_intersect does not return an 'expression' it returns an Array. And IMHO Arrays should be useable where they are returned.

Maybe, could you tell me a little bit more about the word 'expression' you used. Is every return value in PHP a expression until it is assigned to a Variable? If so, is that handled in some part of the Manual?

Thanks
 [2005-06-24 15:37 UTC] tony2001@php.net
See http://www.php.net/manual/en/language.expressions.php for the definition of "expression".
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Nov 22 05:01:29 2024 UTC