|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[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"
/*************************************************/
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 13:00:02 2025 UTC |
No, if you need this behaviour use: cho "Hi! {$$var}"