Re: preg_match and $ sign in PHP5

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 9/6/05, Cabbar Duzayak <cabbar@xxxxxxxxx> wrote:
> Hi,
> 
> I have a regular expression check as:
> 
> preg_match("/$xyz/", $data, $matches);
> 
> And, as you know $xyz means "string starts with xyz". 

No it doesn't - "string starts with xyz" would be "/^xyz/" which
coincidentally avoids your problem of xyz being interpreted as a
variable name.

More generally, if you don't want $xyz interpreted as a variable, then
use single quotes - or if you must use double quotes, then escape the
$ with a backslash.

 -robin

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux