PHP: runkit_import - Manual

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

search for in the

runkit_lint_file runkit_function_rename

Last updated: Fri, 26 Jan 2007

view this page in

# runkit_import

(PECL)

runkit_import -- Process a PHP file importing function and class definitions, overwriting where appropriate

## Описание

bool runkit_import ( string filename [, int flags] )

Similar to include() however any code residing outside of a function or class is simply ignored. Additionally, depending on the value of `flags`, any functions or classes which already exist in the currently running environment will be automatically overwritten by their new definitions.

## Список параметров

`filename`

  Filename to import function and class definitions from

`flags`

  Bitwise OR of the `RUNKIT_IMPORT_*` family of constants.

## Возвращаемые значения

Возвращает `TRUE` в случае успешного завершения или `FALSE` в случае возникновения ошибки.

add a note User Contributed Notes
runkit_import
info at lucasvd dot nl
13-Feb-2007 07:13
`Note that reloading classes does not work, when you're using this extension on the PHP Command Line Interface.`
php at ransico dot com
02-Nov-2006 05:17
`When using this function to override an existing class, you need to be careful in cases where the new definition 'extends' another class - it won't work.
For example,
<?php
// File 1
class BaseCls { }
class TestCls extends BaseCls {
function hi () { echo "Hi"; }
}
runkit_import('test2.php');
?>
<?php
// File 2
class TestCls extends BaseCls {
function hi () { echo "Hi again!"; }
}
?>
will NOT work. In file two, you need to omit the 'extends BaseCls'. Note however, that anything from BaseCls will still be in TestCls since it was defined originally in file 1.
From what I can tell, runkit_import defines and overwrites elements - however it does not delete.`
bbisgod [at] gmail [dot] com
29-Nov-2005 11:19
`I was experiencing problems using this function on a script. I discovered through trial and error that you CANNOT reload a function (or method of a class) if it has been called (e.g, its present in the debug_backtrace). Also you cannot redeclare a function that is used by set_error_handler.
The reasons are logical, but it took me a good 2 days of debugging to find it, hope this saves someone a headache.`
bbisgod [at] gmail [dot] com
29-Nov-2005 10:27
`Heres a nice function to reload the whole program, note, requires PHP5.1:
<?
function reload() {
$files = get_included_files();
foreach($files as $file) {
if (runkit_lint_file($file)) {
runkit_import($file);
} else {
return false;
}
}
}
?>`
add a note
runkit_lint_file runkit_function_rename

Last updated: Fri, 26 Jan 2007
show source | credits | stats | sitemap | contact | advertising | mirror sites
Copyright © 2001-2007 The PHP Group
All rights reserved.
This mirror generously provided by: Yahoo! Inc.
Last updated: Sat Mar 10 10:36:09 2007 PST