Neat program to learn PHP

From: Date: Fri, 20 Apr 2001 15:59:23 +0000
Subject: Neat program to learn PHP
References: 1  Groups: php.windows 
Request: Send a blank email to php-windows+get-6927@lists.php.net to get a copy of this message
Here is a PHP interpreter on a web page. I wrote it to help me learn PHP and it was very helpful. Just copy the code below to a web page, like "eval.php". WARNING! If you put this code on a public server, you should change the hardcoded password (BULLDOG) to something non-obvious, otherwise a hacker could use it to mess with your server. --------------- cut here ---------------- <?php echo "<body onload='window.f.expr.select()'>"; echo "<ul><li>Type a PHP expression.<li>Do not use single quotes."; echo "<li>Multiple statements can be separated with semicolon."; echo "<li>The value of \$r will be displayed."; echo "<form name=f method=GET action=$PHP_SELF>"; if (isset($pw)) echo "<input name=pw type=hidden value='$pw'>"; else echo "Password <input name=pw size=10> &nbsp; <input type=submit><br>"; if (!isset($expr)) $expr='$r = $GLOBALS'; echo "<input name=expr size=60 value='".stripslashes($expr)."'>"; echo "</form><font face='lucida console' size=+1>"; if (isset($pw) and $pw=="BULLDOG" and isset($expr)) { $r = "not set"; $ex = stripslashes($expr).";"; echo "eval('<b> $ex </b>')<p>"; eval($ex); if (gettype($r)=='array') {
    echo "\$r is an array... ";
    foreach ($r as $k => $i) echo "<br>$k = $i";
} else echo "\$r is $r "; } ?> --------------- cut here ----------------
John Henckel          alt. mailto:henckel@iname.com
Zumbro Falls, Minnesota, USA (507) 753-2216 http://geocities.com/jdhenckel/

« previous php.windows (#6927) next »