1.2.1318. Use Constant Instead Of Function¶
Some functioncalls have a constant equivalent, that is faster to execute than calling the function.
This applies to the following functions :
pi() : replace with M_PI
phpversion() : replace with PHP_VERSION
php_sapi_name() : replace with PHP_SAPI_NAME
<?php
// recommended way
echo PHP_VERSION;
// slow version
echo php_version();
?>
See also PHP why pi() and M_PI.
1.2.1318.1. Suggestions¶
Use the constant version, not the function.
1.2.1318.2. Specs¶
Short name |
Structures/UseConstant |
Rulesets |
All, Analyze, CE, CI-checks, PHP recommendations, php-cs-fixable |
Exakat since |
0.8.4 |
PHP Version |
All |
Severity |
Minor |
Time To Fix |
Instant (5 mins) |
Precision |
High |
Available in |