|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2002-10-06 11:27 UTC] iliaa@php.net
[2019-06-12 17:29 UTC] icarus10149 at gmail dot com
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Dec 11 20:00:01 2025 UTC |
parse_url() is over 30 times slower than a PHP code doing the same thing with preg_match. Check this out: parse_url.php: <?php for ($i = 0; $i < 50000; $i++) { $fullurl = "http://www.example.com:80/blah/bing?foo=bar&gazonk=true"; $url = parse_url($fullurl); } ?> $ time php parse_url.php real 1m41.777s user 1m35.770s sys 0m0.200s preg_match.php: <?php for ($i = 0; $i < 50000; $i++) { $fullurl = "http://www.example.com:80/blah/bing?foo=bar&gazonk=true"; preg_match('!^(([^:/?#]+):)?(//([^/:?#]*)(:(\d+))?)?([^?#]*)(\\?([^#]*))?(#(.*))?!', $fullurl, $matches); list(,,$url['scheme'],,$url['host'],,$url['port'],$url['path'],,$url['query']) = $matches; } ?> $ time php preg_match.php real 0m2.950s user 0m2.940s sys 0m0.000s