write php code to a text file

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
sane993
Forum Newbie
Posts: 22
Joined: Thu Jan 16, 2003 9:44 pm

write php code to a text file

Post by sane993 »

Hi, I'm need to write the actual var name ($num) to a text file and not its value.

Here is the script I got so far:

Code: Select all

$writestring = "<?php \n $num = " . $num2 . "\n $numred = " . $numred2 . "\n $numgreen = " . $numgreen2 . "\n $numblue = " . $numblue2 . "\n $numyellow = " . $numyellow2 . "\n $numpurple = " . $numpurple2 . "\n ?>";
And then I just simply put $writestring into the .php file. So how do I actually get $num to show up in the script and not its value?
sane993
Forum Newbie
Posts: 22
Joined: Thu Jan 16, 2003 9:44 pm

Post by sane993 »

Dont owrry I found the answer myself. I was playing around with the script and broke up the strings so its

Code: Select all

$writestring = "<?php \n " . "$" . "num = " . $num2 etc.....
Clever aren't I? :P :D :)
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

you may also use single-quoted strings

Code: Select all

$num = 2;
echo $num;
echo "$num";
echo '$num';
http://www.php.net/manual/en/language.types.string.php
Post Reply