runkit_function_copy
(PECL runkit >= 0.7.0)
runkit_function_copy — Copy a function to a new function name
Description
bool runkit_function_copy
( string
$funcname
, string $targetname
)Parameters
-
funcname
-
Name of existing function
-
targetname
-
Name of new function to copy definition to
Return Values
Returns TRUE
on success or FALSE
on failure.
Examples
Example #1 A runkit_function_copy() example
<?php
function original() {
echo "In a function\n";
}
runkit_function_copy('original','duplicate');
original();
duplicate();
?>
The above example will output:
In a function In a function
See Also
- runkit_function_add() - Add a new function, similar to create_function
- runkit_function_redefine() - Replace a function definition with a new implementation
- runkit_function_rename() - Change a function's name
- runkit_function_remove() - Remove a function definition
- PHP Руководство
- Функции по категориям
- Индекс функций
- Справочник функций
- Изменение поведения PHP
- runkit
- Функция Runkit_Sandbox() - Класс Runkit Sandbox -- это виртуальная машина PHP
- Функция Runkit_Sandbox_Parent() - Класс анти-песочницы для Runkit
- runkit_class_adopt
- runkit_class_emancipate
- runkit_constant_add
- runkit_constant_redefine
- runkit_constant_remove
- runkit_function_add
- runkit_function_copy
- runkit_function_redefine
- runkit_function_remove
- runkit_function_rename
- runkit_import
- runkit_lint_file
- runkit_lint
- runkit_method_add
- runkit_method_copy
- runkit_method_redefine
- runkit_method_remove
- runkit_method_rename
- runkit_return_value_used
- runkit_sandbox_output_handler
- runkit_superglobals
Коментарии
If you don`t have this function, yuo can use this:
<?php
// functions.inc.php : written by Radon8472 (2010-11-16) -- last modified: 2010-12-07
// include guard
if( !defined("FUNCTIONS_INC_PHP") )
{
define("FUNCTIONS_INC_PHP","1.0");
/**
* Copy a function to a new function name
*
* @author: Radon8472
* @version: 1.0 (2010-12-07)
*
* @param: string $funcname Name of existing function
* @param: string $targetname Name of new function to copy definition to
*
* @return: Returns TRUE on success or FALSE on failure.
* @todo: find a way to copy functions with refferece parameters
*/
function func_alias($funcname, $targetname)
{
$ok = true;
if( !function_exists($funcname) ) $ok = false;
if( function_exists($targetname)) $ok = false;
if( $ok )
{
$command = "function ".$targetname."() { ";
$command.= "\$args = func_get_args(); ";
$command.= "return call_user_func_array(\"".$funcname."\", \$args); }";
@eval($command);
if( !function_exists($targetname) ) $ok = false;
}
return $ok;
}
func_alias("func_alias","function_copy");
if(!function_exists("runkit_function_copy"))
{
func_alias("func_alias","runkit_function_copy");
}
}
?>
(PHP 5 >= 5.3.0)
class_alias — Creates an alias for a class
function.class-alias
For (PHP 5 < 5.3.0) you can use following:
<?php
if ( ! function_exists('class_alias')) {
function class_alias($original, $alias) {
eval('abstract class ' . $alias . ' extends ' . $original . ' {}');
}
}
class_alias('print_r', 'printr');
?>