扫码关注官方订阅号
$input=new Input(); $upSet=$input->post(); var_dump($upSet);
class Input{ function post($key){ if(isset($_POST[$key])){ $val=$_POST[$key]; return $val; } }
报错Warning: Missing argument 1 for Input::post(), Notice: Undefined variable: key
业精于勤,荒于嬉;行成于思,毁于随。
解决:
class Input{ public function post($key){ if(isset($_POST[$key])){ $val=$_POST[$key]; return $val; } } $input=new Input(); $upSet=$input->post("demo"); var_dump($upSet);
function post($key = 'default'){}
Input类下面少写个闭合的花括号 }另外post方法里没有传参
微信扫码关注PHP中文网服务号
QQ扫码加入技术交流群
Copyright 2014-2026 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
PHP学习
技术支持
返回顶部
解决:
function post($key = 'default'){}
Input类下面少写个闭合的花括号 }
另外post方法里没有传参