php判断mysqli扩展类是否开启

时间:2016-07-17
php高级版本都支持mysqli扩展类,但是默认情况下,mysqli扩展类是没有开启的,本文章向大家介绍php如何判断mysqli扩展类是否开启,需要的朋友可以参考一下。

php判断mysqli扩展类是否开启,源码如下:

<?php
  /* by http://www.manongjc.com/article/1206.html */
  function mysqlinstalled (){
    if (function_exists ("mysql_connect")){
      return true;
    } else {
      return false;
    }
  }
  function mysqliinstalled (){
    if (function_exists ("mysqli_connect")){
      return true;
    } else {
      return false;
    }
  }
  
  if (mysqlinstalled()){
    echo "<p>The mysql extension is installed.</p>";
  } else {
    echo "<p>The mysql extension is not installed..</p>";
  }
  if (mysqliinstalled()){
    echo "<p>The mysqli extension is installed.</p>";
  } else {
    echo "<p>The mysqli extension is not installed..</p>";
  }
?>

上一页 下一页

原文地址:http://www.manongjc.com/article/1206.html