* (bug 1938) Fix normalization of character references in link text and
[mediawiki.git] / maintenance / eval.php
blobec09bc85bd4b5cc78381a8250f2524b8dca32fe8
1 <?php
2 /**
3 * PHP lacks an interactive mode, but this can be very helpful when debugging.
4 * This script lets a command-line user start up the wiki engine and then poke
5 * about by issuing PHP commands directly.
7 * Unlike eg Python, you need to use a 'return' statement explicitly for the
8 * interactive shell to print out the value of the expression. Multiple lines
9 * are evaluated separately, so blocks need to be input without a line break.
10 * Fatal errors such as use of undeclared functions can kill the shell.
12 * To get decent line editing behavior, you should compile PHP with support
13 * for GNU readline (pass --with-readline to configure).
15 * @package MediaWiki
16 * @subpackage Maintenance
19 $wgForceLoadBalancing = (getenv('MW_BALANCE') ? true : false);
21 /** */
22 require_once( "commandLine.inc" );
24 $line = readconsole( "> " );
26 while ( $line !== false ) {
27 $val = eval( $line . ";" );
28 if( is_null( $val ) ) {
29 echo "\n";
30 } elseif( is_string( $val ) || is_numeric( $val ) ) {
31 echo "$val\n";
32 } else {
33 var_dump( $val );
35 if ( function_exists( "readline_add_history" ) ) {
36 readline_add_history( $line );
38 $line = readconsole( "> " );
41 print "\n";