PHP/Reflection/interface exists

Материал из Web эксперт
Перейти к: навигация, поиск

_exists function

 
bool function_exists (string function_name)
bool method_exists (object object, string method_name)
bool class_exists (string class_name [, bool autoload])
bool interface_exists (string interface_name [, bool autoload])
<?php
  if (function_exists($isemail)){
    if (isemail($email)){
    } else {
      echo "Not a valid e-mail address.";
    }
  } else {
    echo "Function does not exist.<br />";
  }
  
  if (class_exists (myparent)){
    class anyclass extends myparent {
      public $somemember;
      public function dosomething (){
        if (method_exists (parent,"parentmethod")){
        } else {
        }
      }
    }
  } else {
    echo "Class does not exist.<br />";
  }
  if (isset ($_POST["searchterm"])){
  } else {
    echo "You must submit a search term.  Please press the Back button.";
  }
?>