php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #4471 Variable Variables not referenced in echo()/print()
Submitted: 2000-05-16 23:47 UTC Modified: 2000-05-30 20:36 UTC
From: tswan at ics dot olemiss dot edu Assigned:
Status: Closed Package: Scripting Engine problem
PHP Version: 4.0 Release Candidate 2 OS: RedHat 6.0 Linux 2.2.15/Apache 1
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: tswan at ics dot olemiss dot edu
New email:
PHP Version: OS:

 

 [2000-05-16 23:47 UTC] tswan at ics dot olemiss dot edu
I assume that I should can type echo "<B>$foo</B>", I should be able to type echo "<B>$$reference_to_foo</B>"

This doesn't work...

Also...

echo "Hi! $$var";

should be equivalent to 

echo "Hi! " . $$var;

unless I am mistaken...

Included below is a snippet which gives an example...

/*************************************************/
<PRE>
<?
$bob = "Bob Smith";
$variable_name = 'bob';
$variable_value = $$variable_name;

echo "These should all be the same\nBut... they aren't...\n\n";
echo "\"$variable_value\" == \"$$variable_name\"\n";
echo "\"" . $variable_value . "\" == \"" . $$variable_name . "\"\n";
echo "\n";
print ("\"$variable_value\" == \"$$variable_name\"\n");
print ("\"" . $variable_value . "\" == \"" . $$variable_name . "\"\n");
?>
</PRE>
/*************************************************/
Produces:
These should all be the same
But... they aren't...

"Bob Smith" == "$bob"
"Bob Smith" == "Bob Smith"

"Bob Smith" == "$bob"
"Bob Smith" == "Bob Smith"
/*************************************************/

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2000-05-30 20:36 UTC] stas at cvs dot php dot net
No, if you need this behaviour use:

cho "Hi! {$$var}"
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Sep 28 19:01:26 2024 UTC