1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
|
class Util {
function get($variable) {
if(isset($_REQUEST[$variable])) {
return (get_magic_quotes_gpc()?$this->_addslashes($_REQUEST[$variable]):$_REQUEST[$variable]);
}
else return false;
}
function _addslashes($value) {
if(is_string($value)) return addslashes($value);
elseif(is_array($value)) {
foreach ($value As $key => $item) {
if(is_array ($item)) $this->_addslashes($item);
else $value[$key] = addslashes($item);
}
}
return $value;
}
}
if(isset($_REQUEST['sub'])) {
$u = new Util;
$variable = null;
$rep=(!$u->get($variable))?('false'):($u->get($variable));
echo "<pre>"; var_dump($rep); echo "</pre><hr />";
$variable = "seul";
$rep=(!$u->get($variable))?('false'):($u->get($variable));
echo "<pre>"; var_dump($rep); echo "</pre><hr />";
$variable = "plusieurs";
$rep=(!$u->get($variable))?('false'):($u->get($variable));
echo "<pre>"; var_dump($rep); echo "</pre><hr />";
}
?>
<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<input type="hidden" name="seul" value="l'essentiel de toto" />
<select name="plusieurs[]" multiple="true">
<option value="l'apostrophe1" />1</option>
<option value="l'apostrophe2" />2</option>
<option value="l'apostrophe3" />3</option>
</select>
<input type="submit" name="sub" value="ok" />
</form> |
Partager