php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #28752 $$var references not behaving correctly
Submitted: 2004-06-12 10:45 UTC Modified: 2004-06-12 17:35 UTC
From: cpuidle at gmx dot de Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 5CVS-2004-06-12 (dev) OS: WinXP
Private report: No CVE-ID: None
 [2004-06-12 10:45 UTC] cpuidle at gmx dot de
Description:
------------
Two issues exist with php5rc3 when using indirect variables:

Reproduce code:
---------------
<?php
 $test = '';
 $var = 'test';

 if (empty($test)) {
  echo 'test empty';
 }
 // excepted & actual: test empty

 if (empty($$var)) {
  echo 'test empty';
 }
 // expected result: test empty
 // actual result:          <-------!!

 $test = 'doo';
 echo trim($$var);
 // excepted & actual: doo

 if (empty(trim($$var));
 // Fatal error: Can't use function return value in write
 // context in C:\htdocs\test4.php on line 8
 // where is the write context here?      <-------!!
?>


Expected result:
----------------
see above

Actual result:
--------------
see above

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-06-12 17:15 UTC] pollita@php.net
On the first item:  empty($$var) evaluates correctly, recheck your test script to be sure you didn't typo somewhere.

On the second item:  This is expected behavior.  empty() is not a function, but rather a language construct which specicically expects a real variable and not a function return value.  I'll certainly grant the error message is confusing, but no more confusing than PHP4's version of this error:

Parse error: parse error, unexpected T_STRING, expecting T_VARIABLE or '$' in /cvs/php4/28752.php on line 15
 [2004-06-12 17:29 UTC] cpuidle at gmx dot de
Indeed.. 2nd issue not ok, message confusing, accepted.
1st issue:
Found this is working on my 2nd PC, not on first. Difference: working one is running zend optimizer 2.5.0, other is 2.5.2. Disabled 2.5.2 optimizer and bounced apache, now this machine is working, too.
Assumption: zend optimizer 2.5.2 is broken- what am I supposed to do?

Thanks, 
Andi
 [2004-06-12 17:35 UTC] derick@php.net
I'd say file a bug on the optimizer by the Zend guys...
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 16:01:27 2024 UTC