|
Posted by Rik Wasmus on 01/08/08 13:09
On Tue, 08 Jan 2008 14:07:31 +0100, bizt <bissatch@yahoo.co.uk> wrote:
> Hi,
>
> Im trying to write a regular expression in PHP to check if a submitted
> filename has .php on the end of it. For example, filename.html woulod
> return false whereas filename.php would return true.
>
> My code is:
>
> if (ereg ("$.php", $filename))
> return true;
> else
> return false;
>
> Obviously my expression is wrong, could someone please tell me what Im
> doing wrong. Thanks
1. Use PCRE not POSIX, the ereg* function will even disappear in PHP6 it
seems.
2. preg_match('/\.php$/',$filename)
--
Rik Wasmus
[Back to original message]
|