将另一个类的数据插入CURL
问题描述:
I have two class; APIKey and Curl. I can not put the API Key in the header line of the CURL class.
I am trying to add this API Key to the Curl Class.
$this->apiValue
I have work the examples and tried to try them but I have not been successful.
I get Internal 500 error. What could be the problem?
Code:
class APIkey
{
public $apiValue;
public function __construct(string $apiValue)
{
$this->apiValue = $apiValue;
}
public function getApiAna()
{
echo $this->apiValue;
}
}
Result:
Internal 500 Error
我有两个班级; APIKey和Curl。 我不能把API Key放在CURL类的标题行中。 p>
我正在尝试将此API密钥添加到Curl类。 p>
$ this-> apiValue
code> pre>
我已经完成了示例并试图尝试它们但我没有成功。 p>
我收到内部500错误。 可能是什么问题? p>
代码: p>
class APIkey
{
public $ apiValue;
公共函数 __construct(string $ apiValue)
{
$ this-> apiValue = $ apiValue;
}
公共函数getApiAna()
{
echo $ this-> apiValue;
} \ n}
code> pre>
结果: p>
内部500错误 p>
blockquote>
div>
答
You are trying to implement inheritance but not using as expected.
Also calling non-static method as static.
Use like this:
$c = new Curl('8fbb80d7f378f2276246388093439422');
$c->lists($json, $http_status);