Home > Backend Development > PHP Tutorial > PHP detects the running ability of the server_PHP tutorial

PHP detects the running ability of the server_PHP tutorial

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-07-13 10:58:13
Original
924 people have browsed it

php detects the server’s operating capabilities

//Detection function support
function isfun($funName) {
return (false !== function_exists($funName))?'Supported':'Not supported';
}

//Integer operation ability test
function test_int() {
$timeStart = gettimeofday();
for($i = 0; $i < 3000000; $i++) {
$t = 1+1;
}
$timeEnd = gettimeofday();
$time = ($timeEnd["usec"]-$timeStart["usec"])/1000000+$timeEnd["sec"]-$timeStart["sec"];
$time = round($time, 3)."seconds";
return $time;
}

//Floating point computing capability test
function test_float() {
//Get the pi value
$t = pi();
$timeStart = gettimeofday();
for($i = 0; $i < 3000000; $i++) {
//Square root
sqrt($t);
}
$timeEnd = gettimeofday();
$time = ($timeEnd["usec"]-$timeStart["usec"])/1000000+$timeEnd["sec"]-$timeStart["sec"];
$time = round($time, 3)."seconds";
return $time;
}

//IO ability test
function test_io() {
$fp = @fopen(PHPSELF, "r");
$timeStart = gettimeofday();
for($i = 0; $i < 10000; $i++) {
@fread($fp, 10240);
@rewind($fp);
}
$timeEnd = gettimeofday();
@fclose($fp);
$time = ($timeEnd["usec"]-$timeStart["usec"])/1000000+$timeEnd["sec"]-$timeStart["sec"];
$time = round($time, 3)."seconds";
return($time);
}

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/632010.htmlTechArticlephp detects the running ability of the server // The detection function supports function isfun($funName) { return (false !== function_exists($funName))?'Support':'font color=red does not support /font'; } //Integer operation...
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template