[英]Fatal error: Uncaught ArgumentCountError: Too few arguments to function Class::__construct(), 0 passed in and at least 1 expected in PHP7.1
I am learning PHP but I encountered a new problem.我正在学习 PHP,但我遇到了一个新问题。 I would appreciate if you help.
如果您有所帮助,我将不胜感激。
My code:我的代码:
$idTrack = (new Track_Obj)->getIdtCommon($a,$b);
Class Track_Obj{
function __construct( $idtakip, $env = false ) {...}
function getIdtCommon( $idref, $idstudent, $env = false) {...}
}
Error:错误:
Uncaught ArgumentCountError: Too few arguments to function Track_Obj::__construct(), 0 passed in and at least 1 expected in PHP7.1
未捕获的 ArgumentCountError:函数 Track_Obj::__construct() 的参数太少,传入 0 并且在 PHP7.1 中预期至少为 1
Solve:解决:
New code:新代码:
$idTrack = (new Track_Obj($idtakip))->getIdtCommon($a,$b);
or
$class=new Track_Obj($idtakip);
$idTrack = $class->getIdtCommon($a,$b);
Thank you for help and explanation @Phil感谢您的帮助和解释@Phil
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.