2024 年 PHP 日本會議

ReflectionFunction::export

(PHP 5, PHP 7)

ReflectionFunction::export匯出函式

警告

此函式自 PHP 7.4.0 起已遭 *棄用*,並自 PHP 8.0.0 起已遭 *移除*。強烈建議不要依賴此函式。

說明

public static ReflectionFunction::export(字串 $name, 字串 $return = ?): 字串

匯出一個反射函式。

參數

name

要匯出的反射 (Reflection)。

return (回傳值)

設定為 true 將會回傳匯出的結果,而不是直接輸出。設定為 false (預設值) 則會直接輸出。

回傳值

如果 return 參數設定為 true,則匯出結果會以 字串 的形式回傳,否則回傳 null

另請參閱

新增筆記

使用者貢獻的筆記 1 則筆記

hytest at gmail dot com
13 年前
範例

<?php
function title($title, $name)
{
return
sprintf("%s. %s\r\n", $title, $name);
}

echo
ReflectionFunction::export('title',true);

?>

輸出

Function [ <user> function title ] {
@@ /path/to/file.php 2 - 5

- 參數 [2] {
參數 #0 [ <required> $title ]
參數 #1 [ <required> $name ]
}
}
To Top