PHP Conference Japan 2024

runkit7_function_add

(PECL runkit7 >= 未知)

runkit7_function_add新增一個函式,類似於 create_function()

說明

runkit7_function_add(
    字串 $function_name,
    字串 $argument_list,
    字串 $code,
    布林值 $return_by_reference = null,
    字串 $doc_comment = null,
    字串 $return_type = ?,
    布林值 $is_strict = ?
): 布林值
runkit7_function_add(
    字串 $function_name,
    Closure $closure,
    字串 $doc_comment = null,
    字串 $return_type = ?,
    布林值 $is_strict = ?
): 布林值

參數

function_name

要建立的函數名稱

argument_list

以逗號分隔的參數列表

code

組成函數的程式碼

closure

定義函數的 閉包

return_by_reference

函數是否應該通過引用返回。

doc_comment

函數的說明文件註釋。

return_type

函數的返回類型。

is_strict

函數是否應該像在 strict_types=1 的檔案中宣告一樣運作

返回值

成功時返回 true,失敗時返回 false

範例

範例 #1 runkit7_function_add() 範例

<?php
runkit7_function_add
('testme','$a,$b','echo "The value of a is $a\n"; echo "The value of b is $b\n";');
testme(1,2);
?>

以上範例將輸出

The value of a is 1
The value of b is 2

參見

新增註釋

使用者貢獻的註釋

此頁面沒有使用者貢獻的註釋。
To Top