Re: Escaping characters won't work

From: Date: Fri, 15 Nov 2002 00:52:54 +0000
Subject: Re: Escaping characters won't work
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-124544@lists.php.net to get a copy of this message
At 23:53 14.11.2002, Lars Espelid said: --------------------[snip]-------------------- >Try to execute this code: >if (ereg[^0-9], $num)) > print "That's not a number!"; > >result: parsing error, expects ')' on the if-line. You forgot an opening bracket, and need to quote the regex, like if (ereg('[^0-9]', $num)) print "That's not a number!"; >When I write: >echo "HELLO \n"; >echo "WORLD"; > >I get: HELLO WORLD >(on one line!?) You need to tell the browser to create a newline when displaying HTML: echo "HELLO<br>WORLD" will look identical to echo "HELLO<br>\nWORLD" You can also use the nl2br() function to convert all newlines to a line break: echo nl2br("HELLO\nWORLD"); If you display preformatted text you'll see the linebreak: echo "<pre>HELLO\nWORLD</pre>"; -- >O Ernest E. Vogelsinger (\) ICQ #13394035 ^ http://www.vogelsinger.at/

« previous php.general (#124544) next »