Allen, Local variables are indeed cleared at the end of a function, see http://www.php.net/manual/en/language.variables.scope.php for more information. Furthermore, there are numerous ways to use variables within a string, the simplest method is the one that you described by enclosing your variable within your double quoted string. However, you could also use brackets within your string in addition to concatting your string with your variables such as: echo "this is some string" . $variable; I hope this helps. However before asking these sorts of questions of the list, you might want to refresh your memory using the PHP Language Reference, http://www.php.net/manual/en/langref.php. All the information listed above, is also listed there, and explained in significantly more detail. -----Original Message----- From: Allen McCabe [mailto:allenmccabe@xxxxxxxxx] Sent: Thursday, August 06, 2009 3:20 PM To: phpList Cc: ollisso; Martin Scotta Subject: Trying to create a comment function I was trying some new things with php today, and was commenting above each little bit to better see what was working and/or displaying versus what was not. My comment delineator consisted of the following: [code] echo '<br><br><font color="#bbbbbb"><i> this is a comment displayed in html </i></font><br><br>'; [/code] Then I decided to create a cool function to write that code for me every time I wanted to write a comment formatted in HTML, so to write a comment saying "this is a comment", I would call a function: [code] comment("this is a comment"); [/code] It was working wonderfully, until I wanted to display "test of $newComment" as a comment. [code] comment("test of $newComment"); [/code] This rendered a comment that said "test of ". So I added a \ before the $ to make it display properly, but I was wondering if there was a way that the function could work so that it will display anything you type within the quotes in comment(" "). Here is my original code for the function comment() : [code=function comment()] function comment($commentText = "empty comment") { echo '<br><br><font color=#bbbbbb>Comment:</font><br>'; echo '<font color=#bbbbbb><i>'. $newComment .'</i></font><br><br>'; } [/code] This would return gray text in 2 lines, Comment: then a line return with the comment the developer put within the comment() function call in italics. After noticing that I MUST escape the dollar sign for it to display a function name in a comment, I tried the following: [code] function comment($commentText = "empty comment") { $healthy = "\$"; $yummy = "$"; $newComment = str_replace($healthy, $yummy, $commentText); echo '<br><br><font color=#bbbbbb>Comment:</font><br>'; echo '<font color=#bbbbbb><i>'. $newComment .'</i></font><br><br>'; } [/code] This still does not produce the desired results, I still have to escape the $ when I call the comment() function for the variable name to display. Again, not a big deal, but I don't want this to beat me. Anyone have any ideas? Additionally, when I try to echo $newComment, nothing shows on the screen. Is this because variables are reset or set to null, or cleared at the end of a function in which they are used? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php