sebastiaandraaisma Posted February 6, 2007 Share Posted February 6, 2007 Hi, I try to echo out the following: if ($timezone != "NULL") { //If a timezone is available for this country, show time echo "<tr> <td><span class="style3"> Local time in echo ".$time."</span> </td> </tr>" } I get an error because of the double quotes in class="style3" I tried the following: <?php if ($timezone != "NULL") { //If a timezone is available for this country, show time echo ?> <tr> <td><span class="style3"> Local time in <?php echo $time?></span> </td> </tr> <?php } ?> But still got an error. My intention is to show the table cell only when var $timezone has been defined. I read trough my MySQL & PHP bible but could not find the answer All help is apriciated. Kind regards, Sebas. Link to comment https://forums.phpfreaks.com/topic/37252-solved-echo-problem-with-double-quotes/ Share on other sites More sharing options...
kenrbnsn Posted February 6, 2007 Share Posted February 6, 2007 Either escape the double quotes with a backslash, use single quotes in the style value, or use single quotes to delimit you main string or you can use the heredoc format. Ken Link to comment https://forums.phpfreaks.com/topic/37252-solved-echo-problem-with-double-quotes/#findComment-177917 Share on other sites More sharing options...
Jessica Posted February 6, 2007 Share Posted February 6, 2007 echo '<tr> <td><span class="style3"> Local time in '.$time.'</span> </td> </tr>' or echo "<tr> <td><span class=\"style3\"> Local time in $time</span> </td> </tr>" Link to comment https://forums.phpfreaks.com/topic/37252-solved-echo-problem-with-double-quotes/#findComment-177918 Share on other sites More sharing options...
Demonic Posted February 6, 2007 Share Posted February 6, 2007 echo "<tr> <td><span class=\"style3\"> Local time in echo ".$time."</span> </td> </tr>"; } Link to comment https://forums.phpfreaks.com/topic/37252-solved-echo-problem-with-double-quotes/#findComment-177919 Share on other sites More sharing options...
chronister Posted February 6, 2007 Share Posted February 6, 2007 My personal preference is to jump in and out of php when needed like in the first example <?php if ($timezone != "NULL") { //If a timezone is available for this country, show time ?> <tr> <td><span class="style3"> Local time in echo <?=$time ?></span> </td> </tr> <?php } ?> As long as everything else above and below this snippet of code is correct, this method should work just fine. Link to comment https://forums.phpfreaks.com/topic/37252-solved-echo-problem-with-double-quotes/#findComment-177934 Share on other sites More sharing options...
sebastiaandraaisma Posted February 6, 2007 Author Share Posted February 6, 2007 Thank you all for your input, it solved the problem! Link to comment https://forums.phpfreaks.com/topic/37252-solved-echo-problem-with-double-quotes/#findComment-177943 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.