PHP 8.5.0 Alpha 2 available for testing

runkit7_function_add

(PECL runkit7 >= Unknown)

runkit7_function_add Añade una nueva función, similar a create_function()

Descripción

runkit7_function_add(
    string $function_name,
    string $argument_list,
    string $code,
    bool $return_by_reference = null,
    string $doc_comment = null,
    string $return_type = ?,
    bool $is_strict = ?
): bool
runkit7_function_add(
    string $function_name,
    Closure $closure,
    string $doc_comment = null,
    string $return_type = ?,
    bool $is_strict = ?
): bool

Parámetros

function_name

El nombre de la función a crear

argument_list

La lista de argumentos separados por comas

code

El código que compone la función

closure

Una closure que define la función

return_by_reference

Si la función debe devolver por referencia

doc_comment

El comentario de documentación de la función

return_type

El tipo de retorno de la función

is_strict

Si la función debe comportarse como si fuera declarada en un archivo con strict_types=1

Valores devueltos

Esta función retorna true en caso de éxito o false si ocurre un error.

Ejemplos

Ejemplo #1 Un ejemplo de 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);
?>

El ejemplo anterior mostrará :

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

Ver también

add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top