Re: [PHP] Can't escape characters in php??
You're simply missing quotation marks, as far as I can see: if (ereg('[^0-9]', 2002-11-14)) print That's not a number!; Marco -- php|architect - The magazine for PHP Professionals The first monthly worldwide magazine dedicated to PHP programmers Come visit us at http://www.phparch.com! ---BeginMessage--- 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 ')'. 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 can be wrong? Do I miss a library or something?? Thanks, Lars -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php ---End Message--- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Can't escape characters in php??
Oh, WRT the \n: it works--but you're probably outputting to a browser, which ignores the newline and only interprets HTML code. Marco -- php|architect - The magazine for PHP Professionals The first monthly worldwide magazine dedicated to PHP programmers Come visit us at http://www.phparch.com! ---BeginMessage--- 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 ')'. 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 can be wrong? Do I miss a library or something?? Thanks, Lars -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php ---End Message--- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Can't escape characters in php??
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 HELLObr\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 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Can't escape characters in php??
- Original Message - From: Lars Espelid [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Thursday, November 14, 2002 9:59 PM Subject: [PHP] Can't escape characters in php?? Hello, I'm running Apache/1.3.26 and PHP 4.0.5 on WinXP pro. Also '\n' in an echo-expression won't work. It is ignored. code: echo HELLO \n; echo WORLD; result: HELLO WORLD What can be wrong? Do I miss a library or something?? You are using a browser for the output ? when you use \n you'll see a nice newline in the html source your browser expects html so use html code ! (newline in html is br) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php