我有一段代码几乎是准系统,但由于某种原因,它只是拒绝运行:
<?php
require_once "unirest/src/Unirest.php";
$photo_url = "http://api.animetrics.com/img/test/sc.jpg";
// These code snippets use an open-source library.
$response = Unirest::post("<--URL-->",
array(
"X-Mashape-Key" => "<--API Key-->",
"Content-Type" => "application/x-www-form-urlencoded",
"Accept" => "application/json"
),
array(
"selector" => "FACE, EYES, FULL",
"url" => "http://api.animetrics.com/img/test/sc.jpg"
)
);
echo $response;
?>
此代码块直接取自 mashape 网站,我只是下载了 Unirest 文件。我也确信我的路径是正确的。
我进行了一些调查,并尝试在 Unirest 文件中添加一个静态类函数以打印出一些东西,不出所料,它不起作用。
这是我添加的代码块:
<?php
namespace Unirest;
echo "in file";
$file = new File();
$file->printa("abc");
class File
{
public static function printa($a) {
echo $a;
}
....
在同一个文件中,$file->printa("abc");
工作完美,但是当从不同的文件调用时,或者File::printa("abc");
只是拒绝运行。Unirest::printa("abc");
File\Unirest::printa("abc");
我不确定,但我对命名空间有误解吗?我会认为这Unirest::printa("abc");
是访问静态类函数的正确方法吗?
我将不胜感激有关此的任何建议,谢谢。