路径也正确但我仍然不知道为什么它显示的课程没有被发现为致命错误
<?php
ini_set('display_errors', 1);
require_once('../core/Http/Response.php');
use core\Http;
if(class_exists("Response")){
echo "ok";
}
else {
echo "doesn't exist";
}
$r = new Response();
$r->header('test');
?>
&#13;
答案 0 :(得分:0)
在php文件中正常调用,
<?php
ini_set('display_errors', 1);
require_once('../core/Http/Response.php');
use Core\Http\Response;
if(class_exists( 'Core\Http\Response' )){
$r = new Response(); // -OR- $r = new Core\Http\Response();
}else{
die('class doesn\'t exist');
}
$r->header('test');
?>
如果您想在任何控制器中拨打电话,请按以下方式拨打电话
<?php
// Start of the file
ini_set('display_errors', 1);
require_once('../core/Http/Response.php');
use Core\Http\Response;
// your class
class Test extends Test_Controller {
public function test(){
if(class_exists( 'Core\Http\Response' )){
$r = new Response(); // -OR- $r = new Core\Http\Response();
}else{
die('class doesn\'t exist');
}
$r->header('test');
}
}
?>
答案 1 :(得分:0)
<?php
ini_set('display_errors', 1);
require_once dirname(__DIR__) . '/Core/Http/Response.php';
use \Core\Http\Response;
$test = new Response("test response");
echo $test ;
?>