downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | conferences | my php.net

search for in the

runkit_function_remove> <runkit_function_copy
[edit] Last updated: Wed, 19 Jun 2013

view this page in

runkit_function_redefine

(PECL runkit >= 0.7.0)

runkit_function_redefine Reemplazar una definición de función con una nueva implementación

Descripción

bool runkit_function_redefine ( string $funcname , string $arglist , string $code )

Nota: Por defecto, sólo funciones del espacio de usuario pueden ser eliminadas, renombradas, o modificadas. Para controlar funciones internas, la opción runkit.internal_override en php.ini debe ser habilitada.

Parámetros

funcname

Nombre de la función a redefinir

arglist

Nueva lista de argumentos a ser aceptados por la función

code

Nueva implementación de código

Valores devueltos

Devuelve TRUE en caso de éxito o FALSE en caso de error.

Ejemplos

Ejemplo #1 Un ejemplo de runkit_function_redefine()

<?php
function testme() {
  echo 
"Implementación Original de Testme\n";
}
testme();
runkit_function_redefine('testme','','echo "Nueva Implementación de Testme\n";');
testme();
?>

El resultado del ejemplo sería:

Implementación Original de Testme
Nueva Implementación de Testme

Ver también



add a note add a note User Contributed Notes runkit_function_redefine - [2 notes]
up
0
lucato at gmail dot com
1 year ago
Note to users: language constructs (eval, die, exit, isset, unset, echo etc.) which might be confused with functions, cannot be renamed or redefined even with runkit.internal_override.
up
0
corentin dot delorme at linagora dot com
5 years ago
Here is another example with a parameter:

<?php

function hello_world($word) {
  echo
"Original Hello World: $word\n</br>";
}

$helloWorld = 'echo "Redefined Hello World: $word\n</br>";';

hello_world('test1');

runkit_function_redefine('hello_world', '$word', $helloWorld);

hello_world('test2');

?>

 
show source | credits | sitemap | contact | advertising | mirror sites