简体   繁体   English

致命错误:未捕获的 ArgumentCountError:函数 Class::__construct() 的参数太少,传入 0 并且在 PHP7.1 中预期至少为 1

[英]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.

相关问题 PHP Fatal error: Uncaught ArgumentCountError: Too few arguments to function Kit\core::__construct() on PDO class - PHP Fatal error: Uncaught ArgumentCountError: Too few arguments to function Kit\core::__construct() on PDO class 致命错误:未捕获的 ArgumentCountError:函数 AmazonAPI::construct() 的参数太少,通过了 0 - Fatal error: Uncaught ArgumentCountError: Too few arguments to function AmazonAPI::construct(), 0 passed 致命错误:未捕获的 ArgumentCountError:arguments 到 function eregi() 太少,传入 2 - Fatal error: Uncaught ArgumentCountError: Too few arguments to function eregi(), 2 passed in PHP - Behat - 页面对象扩展 - 致命错误:未捕获的 ArgumentCountError:函数 FeatureContext::__construct() 的参数太少 - PHP - Behat - Page Object Extension - Fatal error: Uncaught ArgumentCountError: Too few arguments to function FeatureContext::__construct() "php - 致命错误:未捕获的 ArgumentCountError:函数 PostManager::__construct() 的参数太少" - php - Fatal error: Uncaught ArgumentCountError: Too few arguments to function PostManager::__construct() PHP 致命错误:未捕获的 ArgumentCountError:函数 sendRegistrationErrorNotification() 的参数太少 - PHP Fatal error: Uncaught ArgumentCountError: Too few arguments to function sendRegistrationErrorNotification() Symfony DI:未捕获的 ArgumentCountError:函数 App::__construct() 的参数太少,在第 28 行传入 index.php 的参数为 0,预期为 1 - Symfony DI: Uncaught ArgumentCountError: Too few arguments to function App::__construct(), 0 passed in index.php on line 28 and exactly 1 expected WordPress - WP_Widget:致命错误:未捕获的 ArgumentCountError:arguments 到 function WP_Widget::__construct()太少 - WordPress - WP_Widget : Fatal error: Uncaught ArgumentCountError: Too few arguments to function WP_Widget::__construct() 致命错误:未捕获的 ArgumentCountError:参数太少 - Fatal error: Uncaught ArgumentCountError: Too few arguments 如何修复致命错误:未捕获的 ArgumentCountError:函数 Login::login() 的参数太少,0 已通过? - How to fix Fatal error: Uncaught ArgumentCountError: Too few arguments to function Login::login(), 0 passed?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM