php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #152 Numerical Variables Illegal (Evil?!?)
Submitted: 1998-03-06 16:15 UTC Modified: 1998-04-02 09:06 UTC
From: maddox at ican dot net Assigned: zeev (profile)
Status: Closed Package: Parser error
PHP Version: 3.0b6 OS: Linux 2.0.32 (redhat 5)
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: maddox at ican dot net
New email:
PHP Version: OS:

 

 [1998-03-06 16:15 UTC] maddox at ican dot net
Hi There,
Well it seems that PHP3 doesn't like variables or indirect variables which are numeric.
Unfortunately, This was a feature in PHP/FI 2.0.1 that I used extensively.
(It was handy for while loops)

<?
  $test = 1;
  $1 = "testing";
  echo $$test;
?>

This spits out the result of: Parse error: parse error, expecting `STRING' or `'{'' or `'$'' in /home/httpd/html/rocky/puritytest.php3 on
line 3

It gives me an Illegal variable if I would use $$test in an if statement as:

<? if ($$test == "testing") {
     echo ("TRUE");
   }
?>

All this stuff works in PHP/FI 2.0.1 (with PHP/FI syntax of course)

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [1998-04-02 09:06 UTC] andi
I believe this is intentional.

Andi: Yeah it is, but you could do the following: 
$i = "$j";
$$i
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 10:01:26 2024 UTC