mysqli_connect.php

来自「linux下安装不上mysql5与php5的可用此关联」· PHP 代码 · 共 54 行

PHP
54
字号
<?PHP$runs   = 10000;$times  = array(  'Connect TCP/IP success'      => 0,  'Connect TCP/IP failure'      => 0,  'Connect Socket success'      => 0,  'Connect Socket failure'      => 0,);$description = 'Connect without closing.';$errors = array();$times['Connect TCP/IP success'] = microtime(true);for ($i = 0; $i < $runs; $i++) {  if (!$link = @mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {    $errors[] = sprintf("'Connect TCP/IP success' failure [original code: %s]",                   ($flag_original_code) ? 'yes' : 'no');    break;  }}$times['Connect TCP/IP success'] = microtime(true) - $times['Connect TCP/IP success'];$times['Connect TCP/IP failure'] = microtime(true);for ($i = 0; $i < $runs; $i++) {  if ($link = @mysqli_connect($host, $user, $passwd . '_unknown', $db, $port, $socket)) {    $errors[] = sprintf("'Connect TCP/IP failure' failure [original code: %s]",                  ($flag_original_code) ? 'yes' : 'no');    break;  }}$times['Connect TCP/IP failure'] = microtime(true) - $times['Connect TCP/IP failure']; $times['Connect Socket success'] = microtime(true);for ($i = 0; $i < $runs; $i++) {  if (!$link = @mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {    $errors[] = sprintf("'Connect Socket success' failure [original code: %s]",                  ($flag_original_code) ? 'yes' : 'no');    break;  }}$times['Connect Socket success'] = microtime(true) - $times['Connect Socket success'];$times['Connect Socket failure'] = microtime(true);for ($i = 0; $i < $runs; $i++) {  if ($link = @mysqli_connect($host, $user, $passwd . '_unknown', $db, $port, $socket)) {    $errors[] = sprintf("'Connect Socket failure' failure [original code: %s]",                  ($flag_original_code) ? 'yes' : 'no');    break;  }}$times['Connect Socket failure'] = microtime(true) - $times['Connect Socket failure'];// sort by runtime in descending orderarsort($times);?>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?