classInput.php
<?php
header("Content-Type:text/html; charset=UTF-8");
class Input{
function post($key){
$val=$_POST[$key];
return $val;
}
}
?>
save.php
<?php
header("Content-Type:text/html; charset=UTF-8");
include 'classInput.php';
$input=new Input();
$userName=$input->post('userName');
$msg=$input->post('msg');
然後我直接訪問save.php,報notice的錯誤,請問能否在classInput.php對傳過來的參數進行判斷啊
阿神2017-05-16 13:06:59
把你的類別作了下修改
<?php
class Input{
var $_Get='';
var $_Post='';
function __construct($data){
print_r($data);
$this->_Get = $data['get'];
$this->_Post = $data['post'];
}
function post($key){
$data = $this->_Get;
$val = $data[$key];
return $val;
}
}
//然后调用的时候
include 'classInput.php';
$input=new Input(['get'=>$_GET]);
$userName=$input->post('userName');
echo $userName;
//这样就好了把