php/e03Form.php
<h2>e03Form recursive = form = action</h3>
<h3>preg = regular expression in php</h3>
<?php
$p = $_POST['pattern'] ?? '/a?bc/';
$s = $_POST['subject'] ?? 'abcdebc';
$r = $_POST['repl'] ?? '?bC';
$stsl = $_POST['stsl'] ?? false;
$pP = $stsl ? stripslashes($p) : $p;
?>
<form action="e03Form.php" method="post">
<p>pattern: <input type="text" name="pattern" value="<?php echo htmlspecialchars($p);?>"/>
(stripslashes? <input type="checkbox" name="stsl" <?php echo $stsl ? 'checked' : '';?>/>)
<?php echo 'strlen ' . strlen($p) . ', addslashes ' . strlen($y=addslashes($p)) . ': ' . htmlspecialchars($y)
. ', stripslashes ' . strlen($y=stripslashes($p)) . ': ' .htmlspecialchars($y); ?>
</p><p>subject: <input type="text" name="subject" value="<?php echo htmlspecialchars($s)?>"/>
<?php echo ' === preg_match(preg, subject) ==> ' . preg_match($pP, $s, $mm) . ' match=' . print_r($mm, true); ?>
</p><p>replace: <input type="text" name="repl" value="<?php echo htmlspecialchars($r)?>"/>
<?php echo ' === preg_replace(preg, replace, subject) ==> ' . htmlspecialchars(preg_replace($pP, $r, $s)) ?> </p>
<p><input type="submit" /></p>
<input type="submit" name="btn" value="extra button 2" />
<input type="submit" name="btn" value="extra button 3" />
<input type="submit" name="btn" value="extra button 4, GEt" formmethod="get" />
</form>
<input type="submit" name="btn" value="extra button 5, after form" />
<h3>input</h3>
<ul>
<li>$_SERVER[REQUEST_METHOD] <?php echo $_SERVER["REQUEST_METHOD"]; ?>
</li><li>$_GET <?php echo mylist($_GET); ?>
</li><li>$_POST <?php echo mylist($_POST); ?>
</li></ul>
<?php
echo '<h2>Source ' . __file__ . '</h2>';
highlight_file(__file__);
function myList($a) {
if (! isset($a))
return '-- undefined --';
$r = '<ul>';
foreach ($a as $key => $value) {
$r .= '<li>' . $key . ' ===> ' . $value . '</li>';
}
return $r . '</ul>';
}
?>