[nycphp-talk] Quick little question - variable interpolation
Carlos A Hoyos
cahoyos at us.ibm.com
Thu Oct 17 17:25:53 EDT 2002
try eval
<?php
$string = 'cup';
$name = 'coffee';
$one = 'This is a $string with my $name in it.<br>';
echo $one;
eval ("\\$two = \\"$one\\";");
echo $two;
?>
will print
This is a $string with my $name in it.
This is a cup with my coffee in it.
Adam Fields
<fields at surgam.ne To: NYPHP Talk <talk at nyphp.org>
t> cc:
Subject: [nycphp-talk] Quick little question - variable interpolation
10/17/2002 02:50
PM
Please respond to
talk
This is one of those really easy questions that's difficult to search
for because the search terms look like everything else.
Is there an easy way to do simple variable interpolation on a string?
For example, if I have:
$one = '1';
$two = '= $one';
Is there a way to get $two to equal '= 1' (or whatever $one happens to
contain, obviously)?
--
- Adam
-----
Adam Fields, Managing Partner, fields at surgam.net
Surgam, Inc. is a technology consulting firm with strong background in
delivering scalable and robust enterprise web and IT applications.
http://www.adamfields.com
--- Unsubscribe at http://nyphp.org/list ---
More information about the talk
mailing list