Re: Curious

From: Date: Wed, 28 Mar 2001 06:29:24 +0000
Subject: Re: Curious
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-45834@lists.php.net to get a copy of this message
> I am curious to know why you need to use the /n, and what it actually does, > because I had a page that used them, and i removed them all and it still > works fine. Have a look here (the main manual is down this second) : http://uk.php.net/manual/en/language.types.string.php An example use is as follows : <?php echo "<table>\n"; echo "\t<tr>\n"; echo "\t\t<td>hi</td>\n"; echo "\t</tr>"; echo "</table>\n"; ?> The HTML source will look like : <table> <tr> <td>hi</td> </tr> </table> But if NO \n's or \t's were used, the HTML source would have looked like : <table><tr><td>hi</td></tr></table> It makes for pretty HTML source huh? Granted with the above example we'd write it as plain HTML but it's an example :) Also such whitespace is important when sending mail. Also, some related information exists around here : http://www.php.net/manual/en/function.nl2br.php > Also, is it seen as good or bad practive to use \" only when required or all > the time. > i.e > echo "<img src=test.gif>"; //Doesn't need to use \" > echo "<img src=test.gif alt=\"Test Image\">"; //Only need to use it > on the > alt text. Escape quotes as you need them. In the above case I'd probably either just write it as HTML or do this : echo '<img src="test.gif" alt="Test Image">'; Single quotes can be in double, double can be in single. In this case single quotes are better as PHP doesn't have to interpet anything within single quotes, they're faster! Check out this tutorial for useful advice on using strings (and quotes) : http://www.zend.com/zend/tut/using-strings.php Regards, Philip

« previous php.general (#45834) next »