classInput.php
<?php
header("Content-Type:text/html; charset=UTF-8");
classInput{
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');
Then I accessed save.php directly and reported a notice error. Can I judge the passed parameters in classInput.php?
First, determine whether it is a post request. If it is a post request, then determine whether the value exists.
![](http://img.php.cn/upload/image/000/000/000/3b341bd59322c3cf1241e20dfbd5e588-0.png)
Made some modifications to your class