Re: Escaping characters won't work

From: Date: Fri, 15 Nov 2002 17:41:17 +0000
Subject: Re: Escaping characters won't work
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-124636@lists.php.net to get a copy of this message
Hello, "Ernest E Vogelsinger" <ernest@vogelsinger.at> wrote: > 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!"; > I think I'm missing something here but while the regex might be correct, don't you think the "print ..." part is incorrect? I mean, _negative_ numbers are numbers, no? Wouldn't it be better just to use is_int() or is_numeric()? - E ...[snip]...

« previous php.general (#124636) next »