method_exists() 函數檢查類方法是否存在。
用法
method_exists(object, name_of_method)
參數
object − 對象實例或類名
name_of_method - 方法名稱
返回
如果已為給定對象定義了 method_name 給出的方法,則 method_exists() 函數返回 TRUE,否則返回 FALSE。
示例
以下是一個例子 -
<?php
$directory = new Directory('.'); var_dump(method_exists($directory,'anything'));
?>
輸出
bool(false)
示例
<?php
var_dump(method_exists('Directory','read'));
?>
輸出
bool(true)
相關用法
- PHP metaphone()用法及代碼示例
- PHP mhash_get_hash_name()用法及代碼示例
- PHP mysqli_get_server_info()用法及代碼示例
- PHP money_format()用法及代碼示例
- PHP mysqli_data_seek()用法及代碼示例
- PHP mysqli_insert_id()用法及代碼示例
- PHP mysqli_fetch_assoc()用法及代碼示例
- PHP mkdir()用法及代碼示例
- PHP mysqli_connect_error()用法及代碼示例
- PHP mhash_keygen_s2k()用法及代碼示例
- PHP microtime()用法及代碼示例
- PHP mysqli_fetch_all()用法及代碼示例
- PHP mt_rand( )用法及代碼示例
- PHP mysqli_next_result()用法及代碼示例
- PHP mysqli_stmt_affected_rows()用法及代碼示例
- PHP mime_content_type()用法及代碼示例
- PHP mysqli_begin_transaction()用法及代碼示例
- PHP mysqli_real_escape_string()用法及代碼示例
- PHP mysqli_fetch_lengths()用法及代碼示例
注:本文由純淨天空篩選整理自Chandu yadav大神的英文原創作品 method_exists() function in PHP。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。