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
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
1 + 9 = ?
Subscribe to this entry?

 
 [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

Add a Patch

Pull Requests

Add a Pull Request

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 Mar 29 12:01:27 2024 UTC