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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
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: Mon Jul 22 02:01:28 2024 UTC