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. Quote Link to comment 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 Quote Link to comment 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>" Quote Link to comment 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>"; } Quote Link to comment 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. Quote Link to comment 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! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.