PHP 8.5.0 Alpha 2 available for testing

runkit7_function_redefine

(PECL runkit7 >= Unknown)

runkit7_function_redefine Sustituye una definición de función por una nueva implementación

Descripción

runkit7_function_redefine(
    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_redefine(
    string $function_name,
    Closure $closure,
    string $doc_comment = null,
    string $return_type = ?,
    bool $is_strict = ?
): bool

Nota: Por defecto, solo las funciones definidas por el usuario pueden ser eliminadas, renombradas o modificadas. Para sobreescribir funciones internas, se debe activar la configuración runkit.internal_override en el archivo php.ini del sistema entero.

Parámetros

function_name

El nombre de la función a redefinir

argument_list

La nueva lista de argumentos a aceptar por la función

code

El código de la nueva implementació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 se comporta como si estuviera declarada en un fichero 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_redefine()

<?php
function testme() {
echo
"Original Testme Implementation\n";
}
testme();
runkit7_function_redefine('testme','','echo "New Testme Implementation\n";');
testme();
?>

El ejemplo anterior mostrará :

Original Testme Implementation
New Testme Implementation

Ver también

add a note

User Contributed Notes

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