Make WordPress Core


Ignore:
Timestamp:
05/20/2022 05:36:23 PM (4 years ago)
Author:
SergeyBiryukov
Message:

Code Modernization: Replace phpversion() function calls with PHP_VERSION constant.

phpversion() return value and PHP_VERSION constant value are identical, but the latter is several times faster because it is a direct constant value lookup compared to a function call.

Props ayeshrajans, jrf, mukesh27, costdev, hellofromTonya, SergeyBiryukov.
Fixes #55680.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/class-wp-debug-data.php

    r53011 r53426  
    678678                }
    679679
    680                 if ( function_exists( 'phpversion' ) ) {
    681                         $php_version_debug = phpversion();
    682                         // Whether PHP supports 64-bit.
    683                         $php64bit = ( PHP_INT_SIZE * 8 === 64 );
    684 
    685                         $php_version = sprintf(
    686                                 '%s %s',
    687                                 $php_version_debug,
    688                                 ( $php64bit ? __( '(Supports 64bit values)' ) : __( '(Does not support 64bit values)' ) )
    689                         );
    690 
    691                         if ( $php64bit ) {
    692                                 $php_version_debug .= ' 64bit';
    693                         }
    694                 } else {
    695                         $php_version       = __( 'Unable to determine PHP version' );
    696                         $php_version_debug = 'unknown';
     680                $php_version_debug = PHP_VERSION;
     681                // Whether PHP supports 64-bit.
     682                $php64bit = ( PHP_INT_SIZE * 8 === 64 );
     683
     684                $php_version = sprintf(
     685                        '%s %s',
     686                        $php_version_debug,
     687                        ( $php64bit ? __( '(Supports 64bit values)' ) : __( '(Does not support 64bit values)' ) )
     688                );
     689
     690                if ( $php64bit ) {
     691                        $php_version_debug .= ' 64bit';
    697692                }
    698693
Note: See TracChangeset for help on using the changeset viewer.