📜 ⬆️ ⬇️

Experiments with replacement functions in php

A few months ago, I became interested in the question: what is faster - eregi_replace or str_replace? When you just need to replace one piece of text with another piece.
I wrote some script that time counted, corrected there one for another and vice versa, but it turned out garbage. Still, on a work machine, measuring milliseconds is weird :).

And recently I caught up that you can measure everything in one script and immediately count it.
As a result, it was found that str_replace with a simple replacement by two orders of magnitude faster than eregi. Ohrenel from the result.

UDP Shoved into the preg_replace test. Now I understand why, from the sixth version of PHP, POSIX regulars are going to be removed altogether.
')
Script code:
http://drusha.msk.ru/times.php

Source: https://habr.com/ru/post/26275/


All Articles