php如何打印出類的所有方法

php打印出類的所有方法的方法:可以利用get_class_methods()函數(shù)來實現(xiàn),它可以返回由類的方法名組成的數(shù)組。如果出錯,則函數(shù)返回NULL。

成都創(chuàng)新互聯(lián)專注于蛟河網(wǎng)站建設(shè)服務(wù)及定制,我們擁有豐富的企業(yè)做網(wǎng)站經(jīng)驗。 熱誠為您提供蛟河營銷型網(wǎng)站建設(shè),蛟河網(wǎng)站制作、蛟河網(wǎng)頁設(shè)計、蛟河網(wǎng)站官網(wǎng)定制、微信小程序定制開發(fā)服務(wù),打造蛟河網(wǎng)絡(luò)公司原創(chuàng)品牌,更為您提供蛟河網(wǎng)站排名全網(wǎng)營銷落地服務(wù)。

get_class_methods()函數(shù)可以返回由類的方法名組成的數(shù)組。如果出錯,則返回 NULL。

(推薦教程:php視頻教程)

語法格式:

get_class_methods ( mixed $class_name )

舉例:

<?php

class myclass {
    // constructor
    function myclass()
    {
        return(true);
    }

    // method 1
    function myfunc1()
    {
        return(true);
    }

    // method 2
    function myfunc2()
    {
        return(true);
    }
}

$class_methods = get_class_methods('myclass');
// or
$class_methods = get_class_methods(new myclass());

foreach ($class_methods as $method_name) {
    echo "$method_name\\n";
}

?>

輸出結(jié)果:

myclass
myfunc1
myfunc2

相關(guān)推薦:php培訓(xùn)

標(biāo)題名稱:php如何打印出類的所有方法
URL網(wǎng)址:http://www.muchs.cn/article40/cjhhho.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供微信公眾號虛擬主機、網(wǎng)站排名移動網(wǎng)站建設(shè)、外貿(mào)建站網(wǎng)站改版

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

微信小程序開發(fā)