久久久久久久视色,久久电影免费精品,中文亚洲欧美乱码在线观看,在线免费播放AV片

<center id="vfaef"><input id="vfaef"><table id="vfaef"></table></input></center>

    <p id="vfaef"><kbd id="vfaef"></kbd></p>

    
    
    <pre id="vfaef"><u id="vfaef"></u></pre>

      <thead id="vfaef"><input id="vfaef"></input></thead>

    1. 站長資訊網(wǎng)
      最全最豐富的資訊網(wǎng)站

      php怎么判斷類存不存在

      在php中,可以使用class_exists()函數(shù)來判斷指定類存不存在,該函數(shù)的作用就是檢查類是否已定義,語法為“class_exists('類名')”;如果指定類已經(jīng)定義(存在),則返回true,否則返回false。

      php怎么判斷類存不存在

      本教程操作環(huán)境:windows7系統(tǒng)、PHP7.1版、DELL G3電腦

      在php中,可以使用class_exists()函數(shù)來判斷指定類存不存在。

      class_exists()函數(shù)可以檢查指定的類是否已定義。

      語法:

      class_exists(string $class, bool $autoload = true): bool
      • class:類名。名字的匹配是不分區(qū)大小寫的。

      • autoload:是否默認調(diào)用 __autoload。

      返回值:

      • 如果由 class 所指的類已經(jīng)定義,此函數(shù)返回 true,否則返回 false。

      示例1:檢查類HelloWorld是否已定義

      <?php    if (class_exists('HelloWorld')) {       $helloworld = new HelloWorld();    } ?>

      class_exists() 默認將會嘗試調(diào)用 _autoload,如果不想讓 class_exists() 調(diào)用_autoload,可以將 autoload 參數(shù)設(shè)為 FALSE。

      示例2:autoload 參數(shù)例子

      <?php function __autoload($class) {     include($class . '.php');      // Check to see if the include declared the class     if (!class_exists($class, false)) {         trigger_error("Unable to load class: $class", E_USER_WARNING);     } }  if (class_exists('MyClass')) {     $myclass = new MyClass(); }  ?>

      推薦學習:《PHP視頻教程》

      贊(0)
      分享到: 更多 (0)
      網(wǎng)站地圖   滬ICP備18035694號-2    滬公網(wǎng)安備31011702889846號