Reply to Re: [PHP] preg_match

Your name:

Reply:


Posted by Edin Kadibašić on 10/20/13 11:24

Jasper Bryant-Greene wrote:
> John Nichel wrote:
>
>> Personally, I have never used \\ in PCRE when looking for things like
>> spaces (\s), word boundraries (\b), etc. and it's all worked out fine.
>
>
> It will work fine, but only because those (\s and \b) just happen to not
> be special characters in PHP *at this time*.
>
> It's sloppy programming because the backslash is known to be a special
> character, and \s or \b could conceivably become special characters at
> some time in the future. It's unlikely, but possible.
>
> Not only that, but it makes it more likely that you'll forget and put \n
> when you meant \\n, \r when you meant \\r, \t when you meant \\t, and so
> on...

Also people thinking that PHP's single-quoted strings don't have any
escape sequences run into trouble when they have backslash as the last
character of the string:

$path = 'c:\';

This will give you parse error because the parser would think that you
wanted literal ' character and looks in vain for the string end. The
correct line should be:

$path = 'c:\\';

Edin

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация