WP_CLI\Utils

get_php_binary()WP-CLI 1.0

Get the path to the PHP binary used when executing WP-CLI.

Environment values permit specific binaries to be indicated.

No Hooks.

Return

String.

Usage

get_php_binary();

get_php_binary() code WP-CLI 2.8.0-alpha

function get_php_binary() {
	// PHAR installs always use PHP_BINARY.
	if ( inside_phar() ) {
		return PHP_BINARY;
	}

	$wp_cli_php_used = getenv( 'WP_CLI_PHP_USED' );
	if ( false !== $wp_cli_php_used ) {
		return $wp_cli_php_used;
	}

	$wp_cli_php = getenv( 'WP_CLI_PHP' );
	if ( false !== $wp_cli_php ) {
		return $wp_cli_php;
	}

	return PHP_BINARY;
}