jimbudd
-
Posts
2 -
Joined
-
Last visited
Never
Posts posted by jimbudd
-
-
hi i CAN get my php write file script to dynamically insert a name,
but CANT get the name in the result file, to be inside inverted commas as the script and wont parse.
eg.
my create file script:
[!--coloro:#3333FF--][span style=\"color:#3333FF\"][!--/coloro--]$content3 = '<?php $thisbio = '. $username .'";?>
';
write_file("$webpath/$username/ID.php","$content3\n");[!--colorc--][/span][!--/colorc--]
dynamically loads the user and writes the result ID.php file:
[!--coloro:#3333FF--][span style=\"color:#3333FF\"][!--/coloro--]<?php
$thisbio = blackbetty;
?>[!--colorc--][/span][!--/colorc--]
but here's my problem, the result needs to look like this:
[!--coloro:#3333FF--][span style=\"color:#3333FF\"][!--/coloro--]<?php
$thisbio = 'blackbetty';
?>[!--colorc--][/span][!--/colorc--]
so my newbie attempt was this, but of course wont parse:
[!--coloro:#3333FF--][span style=\"color:#3333FF\"][!--/coloro--]$content3 = '<?php $thisbio = ''. $username .''";?>
';
write_file("$webpath/$username/ID.php","$content3\n");[!--colorc--][/span][!--/colorc--]
so can someone please help me to write this correctly??
many thanks,
jimbudd
write file
in PHP Coding Help
Posted
[!--quoteo(post=357207:date=Mar 22 2006, 01:13 AM:name=akitchin)--][div class=\'quotetop\']QUOTE(akitchin @ Mar 22 2006, 01:13 AM) [snapback]357207[/snapback][/div][div class=\'quotemain\'][!--quotec--]
if you ever want to insert a character that you're using as a string delimiter (that is, double or single quotes), you can escape it to have its delimitation meaning nulled. in lighter terms, escaping a character makes it mean nothing:
[code]$content3 = '<?php $thisbio = \''. $username .'\';?>';[/code]
notice that i escape (add a backslash) before the two single quotes that i want to appear in the string itself. an alternative would be to use double quotes, like so:
[code]$content3 = "<?php \$thisbio = '$username';?>";[/code]
here we have to escape the first $ since otherwise PHP will try to insert the actual value of $thisbio, not simply insert a literal $thisbio.
[/quote]