require_once()can n中的PHP致命错误

require_once()can n中的PHP致命错误,php,fatal-error,require-once,Php,Fatal Error,Require Once,我在其他目录中有一个php文件,我想使用它的一些数据,但当我需要_once()该文件时,我看到以下错误: 致命错误:require_once():无法在第20行的E:\wamp\www\newmvc\index.php中打开所需的“/Controller/UserController”(include_path=”;C:\php\pear”) newmvc是我的根 我确信没有拼写错误,我有文件 $Controller="user"; $param=array(); $className=ucfi

我在其他目录中有一个php文件,我想使用它的一些数据,但当我需要_once()该文件时,我看到以下错误:

致命错误:require_once():无法在第20行的E:\wamp\www\newmvc\index.php中打开所需的“/Controller/UserController”(include_path=”;C:\php\pear”)

newmvc是我的根 我确信没有拼写错误,我有文件

$Controller="user";
$param=array();
$className=ucfirst($Controller)."Controller";
$controllerfilepath="/Controller/".$className;
require_once "$controllerfilepath";

我想您忘了为类文件名添加扩展名
.php

$controllerfilepath="/Controller/" . $className . ".php";

/Controller
指的是根目录“Controller”,它听起来有点错误,除非您确实将文件直接存储在根目录下。也许看一看你不需要一次的php文件,只有folderyeah非常感谢。