PHP Tip: without the need don’t use RegExp

In PHP than regular expressions, there is a large number of text-processing functions, which in some cases can replace them, while saving resources server.

Incorrect: <? $new = ereg_replace(«-»,»_»,$str); ?>
Correct: <? $new = str_replace(«-»,»_»,$str); ?>
Incorrect: <? preg_match(«/(\..*?)$/»,$str,$reg); ?>
Correct: <? substr($str,strrpos($str,)); ?>

Добавить комментарий