找不到显示Php的类 [英] Class not found showing Php
问题描述
我的index.php文件存在于public_html/myapp/files
目录中,而我试图使用存在于同一目录public_html/myapp/files
中的库.但是我遇到了错误
My index.php file exist in public_html/myapp/files
directory,And i am trying to use library which exist in same directory public_html/myapp/files
. But I am getting error
找不到"SightengineClient"类 /home/public_html/myapp/files/index.php在第7行
Class 'SightengineClient' not found in /home/public_html/myapp/files/index.php on line 7
我哪里错了? 这是我的代码
Where i am wrong ? Here is my code
namespace Tests;
use SightengineClient;
$client = new SightengineClient('myapikey', 'secretkey');
$output = $client->check(['nudity'])->set_url('https://d3m9459r9kwism.cloudfront.net/img/examples/example7.jpg');
echo "<pre>";print_R($output);
推荐答案
如果您不使用composer管理项目(生成自动加载),则使用使用 kewyord将不包括该类.以这种方式要求文件:
Using the use kewyord will not include the class if you are not managing your project with composer(generating the autoload ) will you can require the file in this way :
require_once('path to SightengineClient file');
$t = new SightengineClient;
使用require_once将确保您只被包括一次 文件.
Using require_once will ensure that you are include only one time the file .
这篇关于找不到显示Php的类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!