I agree that this functionality would be nice to have in CLI. I have tried to compile the code attached, but with no luck. Even after fixing obvious syntax errors, the compiled php just ignores passed string.
> i just looked at the code for a possibility to extend CLI to execute code > without using files. For example: > > php -- 'echo "Hello World";' I would like to see a "normal" command line option like "-r" (for run) instead of --. This because we might decide to use long gnu style command line options (like "--help") in the future. > I saw that only files can be executed, so i had to pacth the following files: > Zend/zend_compile.h: > added new constant ZEND_HANDLE_STRING > added new prototype for zend_execute_code > Zend/zend.c: > added function zend_execute_code which executed a prepended file a > code string and an appended file > main/main.c: > make function php_execute_script recognize type ZEND_HANDLE_STRING > and invoke zend_execute_code instead zend_execute_scripts > on that type. > sapi/cli/php_cli.c > added switch -- in php_cli_usage > function main: > stop interpreting argumants after -- > setting up information for -- with file_handle.type = > ZEND_HANDLE_STRING > the code pointer uses file_handle.filename The implementation of this feature should IMHO be done differently. Probably the best way would be to use behaviour variable with a new value (for example PHP_MODE_DIRECT) and to add -r <code> in the main switch() statement. > The code compiles but i cannot build an executable. I only have CYGWIN > where i am now and > the CVS version does not build them.... I have no problems building executable version of php using cygwin with the latest version of autoconf and libtool installed. I configure it with --without-xml since this option was knows to cause trouble. Anyway, branch date for PHP 4.2.0 is Wednesday (tomorrow) so I think we would have to wait until the next version to implement these features, unless there is overwhelming wish to include this in 4.2. Edin -- PHP Development Mailing List <http://www.php.net/> To unsubscribe, visit: http://www.php.net/unsub.php