Re: function right on PHP3, wrong on PHP4
| From: | Nick Talbott | Date: | Mon, 03 Jul 2000 16:59:56 +0000 |
| Subject: | Re: function right on PHP3, wrong on PHP4 | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-4531@lists.php.net to get a copy of this message | ||
>I greated this function:
>
>function is_numb($val,$min,$max){
> if($res = ereg("[0-9]{$min,$max}",$val)){return $val;}else{return
>false;}
>}
>
>and with PHP3 works correctly, while instead with PHP4 it generates the
>following error:
I think you'll find this is due to one of the documented differences between
PHP3 and PHP4.
Here's a quote from the documents on the PHP site:
The following letter combination is not supported within encapsulated
strings: "{$". If you have a string that includes this letter combination,
for example, print "{$somevar"; (which printed the letter { and the contents
of the variable $somevar in PHP 3.0), it will result in a parse error under
Zend. In this case, you would have to change the code to print "\{$somevar";
This incompatability is due to the full variable reference within quoted
strings feature added in Zend.
Your expression includes the {$ sequence.
Try changing the code as described above and see if it works for you.
- Regards
Nick Talbott
IT Policy and Strategy Manager, Powys County Council, UK
email nickt@powys.gov.uk
FAX +44 (0) 1597 824781
web http://www.powys.gov.uk and http://www.powysweb.co.uk