Re: Can't escape characters in php??

From: Date: Thu, 14 Nov 2002 23:59:53 +0000
Subject: Re: Can't escape characters in php??
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-124538@lists.php.net to get a copy of this message
Hello, Lars Espelid wrote:
Hello, I'm running Apache/1.3.26 and PHP 4.0.5 on WinXP pro. The following code is taken from the book mastering PHP 4.1 and is supposed to work: if (ereg([^0-9], "2002-11-14"))
    print "That's not a number!";
It won't work for me. I get a parse error expecting a ')'.
Is this the only code on the page? Try quoting your expression, and bracketing your if check i.e. if ( ereg ( "[^0-9]", "2002-11-14" ) ) { print "That's not a number!"; }
I have also tried other regular expressions, but almost all of them fails. One that works: if (ereg("....-..-..", "2002-11-14")) Also '\n' in an echo-expression won't work. It is ignored. code: echo "HELLO \n"; echo "WORLD"; result: HELLO WORLD
What did you expect this to do? Most, if not all browsers don't start a new line when they encounter a new line or carrige return unless it's encased by <pre></pre> tags. Try this... echo "HELLO<br>\n"; echo "WORLD";
What can be wrong? Do I miss a library or something?? Thanks, Lars
-- By-Tor.com It's all about the Rush http://www.by-tor.com

« previous php.general (#124538) next »