php - 初始化类已经抛出缺少的参数
问题描述
我不知道我在做什么错了。甚至没有使用该函数,而且我已经在错误日志中丢失了左右参数,奇怪的是它仍然可以完成工作并像我的其他类一样返回想要的信息,但我不知道为什么这两个不只是闭嘴.
<?php
include_once "classes/getT.php";
include_once "classes/getC.php";
$getT = new getT();
$getC = new getC();
?>
两个包含的代码完全相似,只是用于 CURL 和其他变量传递的不同 URL。
<?php
class getT{
function getT ($tID, $count, $offset) {
$url = "...?tId=$tID&count=$count&offset=$offset";
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
$curl_response = curl_exec($curl);
curl_close($curl);
return $curl_response;
}
}
?>
解决方案
Seems like you try to use old-style php constructor (via method with name same as name of the class). It have three arguments, and you must provide they when you create new object of your class:
$getT = new getT($tID, $count, $offset);
$getC = new getC($tID, $count, $offset);
推荐阅读
- python - 在 Anaconda 之外使用 Python 包
- c - 我得到了意想不到的输出
- angular - 在angular7中禁用以前日期的ng-bootstrap日期和时间
- spring - 如何让用户发送电子邮件?
- javascript - 控制台说注册表单不存在 onsubmit 功能,尽管它显然存在
- python - Python Read/Parse Account:Password txt file line by line
- node.js - AWS Lambda 无法调用没有 VPC 的另一个 AWS Lambda - NodeJs
- apache-camel - 骆驼并行处理:RouteDefinition 无法转换为 org.apache.camel.model.TryDefinition
- rcpp - 在 Rcpp 函数中停止(作为包的一部分)以调试模式结束
- angular - 如何在点击时将 AutoFocus 指令添加到输入?