[wp-trac] [WordPress Trac] #55680: Replace `phpversion()` function calls with PHP_VERSION
WordPress Trac
noreply at wordpress.org
Wed May 4 20:01:05 UTC 2022
#55680: Replace `phpversion()` function calls with PHP_VERSION
-------------------------+-----------------------------
Reporter: ayeshrajans | Owner: (none)
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting Review
Component: General | Version: trunk
Severity: normal | Keywords: has-patch
Focuses: performance |
-------------------------+-----------------------------
We use several `phpversion()` functions in WordPress core, which I propose
to be replaced with `PHP_VERSION` constants.
`phpversion()` return value and `PHP_VERSION` constant value are
identical, but the former is about 3 times slower because it is a function
call compared to a direct constant value lookup.
Simple benchmark:
{{{#!php
<?php
$start = microtime(true);
for ($i = 0; $i < 1000000; $i++) {phpversion();}
echo microtime(true) - $start;
echo "\r\n";
$start = microtime(true);
for ($i = 0; $i < 1000000; $i++) {PHP_VERSION;}
echo microtime(true) - $start;
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/55680>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list