//save it index.php in a root folder
/*
if($_SERVER["REQUEST_METHOD"]!='GET'){
echo('it`s a POST');
}else{
echo('it`s a GET');
}
*/
$_REQ =& $_SERVER["REQUEST_METHOD"];
($_REQ=='POST')and($what='it`s a POST');
($_REQ=='GET')and($what='it`s a GET');
isset($what) and print($what);
?>
<form method="POST" action="">
<input type="text" name="postbaby" value="sadasdsa">
<input type="submit" value="POST THAT">
</form>
<br>
<form method="GET" action="">
<input type="text" name="getbaby" value="sadasdsa">
<input type="submit" value="GET THAT">
</form>
<hr><?php
phpinfo();
?>
<?php
//save it index.php in a root folder
/*
if($_SERVER["REQUEST_METHOD"]!='GET'){
echo('it`s a POST');
}else{
echo('it`s a GET');
}
*/
class forms {
public static function type(){
return $_SERVER["REQUEST_METHOD"];
}
public static function post($f){
(self::type()=='POST')and $f();
}
public static function get($f){
(self::type()=='GET')and $f();
}
}
?>
<form method="POST" action="">
<input type="text" name="postbaby" value="sadasdsa">
<input type="submit" value="POST THAT">
</form>
<br>
<form method="GET" action="">
<input type="text" name="getbaby" value="sadasdsa">
<input type="submit" value="GET THAT">
</form>
<hr><?php
forms::post(function(){
$what='it`s a POST';echo($what);
});
forms::get(function(){
$what='it`s a GET';echo($what);
});
//phpinfo();
?>
No comments:
Post a Comment