第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定

哪里錯(cuò)了啊?

這是我的結(jié)構(gòu)文件:/var/www/html/test/MVC/

├── test
│?? ├── MVC
│?? │?? ├── Controller
│?? │?? │?? └── testController.class.php
│?? │?? ├── function.php
│?? │?? ├── index.php
│?? │?? ├── Model
│?? │?? │?? └── testModel.class.php
│?? │?? ├── test.php
│?? │?? └── View
│?? │?????? └── testView.class.php
│?? └── others

/test/MVC/Controller/testController.class.php

<?php

class?testController{
????function?show(){
????????//$testModel?=?new?testModel();
????????$testModel?=?Model('test');
????????$data=$testModel->get();
????????//$testView?=?new?testView();
????????$testView?=?View('test');
????????$testView->display($data);
????}
}
?>

/test/MVC/Model/testModel.class.php

<?php

????class?testModel{
????????function?get(){
????????????echo?"Hello?World!";
????????}
????}
?>

/test/MVC/View/testView.class.php

<?php

class?testView{
????function?display($data){
????????echo?$data;
????}
}

?>

function.php

<?php
????function?Controller($name,$method){
????????require_once('/test/MVC/Controller/'.$name.'Controller.class.php');
????????//$testController?=?new?testController();
????????//$testController->show();

????????eval('$obj?=?new'.$name.'Controller();?$obj->'.$method.'();');

????}

????Controller('test','show');

????function?Model($name){
????????require_once('/test/MVC/Model/'.$name.'Model.class.php');
????????//$testModel?=?new?testModel();
????????eval('$obj?=?new?'.$name.'Model();');
????????return?$obj;
????}

????function?View($name){
????????require_once('/test/MVC/View/'.$name.'View.class.php');
????????//$testView?=?new?testView();
????????eval('$obj?=?new?'.$name.'View();');
????????return?$obj;
????}

????function?daddslashes($str){
????????return?(!get_magic_quotes_gpc())?addslashes($str):$str;
????}

?>

index.php

<?php
????//url形式?index.php?controller=控制器名&method=方法名
????require_once('function.php');
????$controllerAllow?=?array('test','index');
????$methodAllow?=?array('test','index','show');

????$controller?=?in_array($_GET['controller'],?$controllerAllow)?daddslashes($_GET['controller']):'index'?;
????$method?=?in_array($_GET['method'],$methodAllow)?daddslashes($_GET['method']):'index';

????Controller($controller,$method);

?>

報(bào)的錯(cuò)誤信息:

http://127.0.0.1/test/MVC/

Warning:?require_once(/test/MVC/Controller/testController.class.php):?
failed?to?open?stream:?No?such?file?or?directory?in?
/var/www/html/test/MVC/function.php?on?line?3

Fatal?error:?
require_once():?Failed?opening?required?
'/test/MVC/Controller/testController.class.php'?
(include_path='.:/usr/local/php/lib/php')?in?
/var/www/html/test/MVC/function.php?on?line?3

哪里錯(cuò)了啊……看不出來(lái)……


解決方案:

function.php

<?php
????function?Controller($name,$method){
????????require_once('Controller/'.$name.'Controller.class.php');
????????//$testController?=?new?testController();
????????//$testController->show();

????????eval('$obj?=?new'.$name.'Controller();?$obj->'.$method.'();');

????}

????Controller('test','show');

????function?Model($name){
????????require_once('Model/'.$name.'Model.class.php');
????????//$testModel?=?new?testModel();
????????eval('$obj?=?new?'.$name.'Model();');
????????return?$obj;
????}

????function?View($name){
????????require_once('View/'.$name.'View.class.php');
????????//$testView?=?new?testView();
????????eval('$obj?=?new?'.$name.'View();');
????????return?$obj;
????}

????function?daddslashes($str){
????????return?(!get_magic_quotes_gpc())?addslashes($str):$str;
????}

?>


正在回答

5 回答

路徑問(wèn)題。在linux里面 require 使用絕對(duì)路徑 / 開(kāi)頭的話,會(huì)從linux的根目錄開(kāi)始找,而不是你網(wǎng)站的根目錄。

0 回復(fù) 有任何疑惑可以回復(fù)我~

require_once('Controller/'.$name.'Controller.class.php');
換成這個(gè)就打印出Hello World!了!

0 回復(fù) 有任何疑惑可以回復(fù)我~

? require_once('/test/MVC/Controller/'.$name.'Controller.class.php');改成

? require_once('/Controller/'.$name.'Controller.class.php');試試

0 回復(fù) 有任何疑惑可以回復(fù)我~
#1

全民工作狂 提問(wèn)者

然而并沒(méi)有用……
2015-10-08 回復(fù) 有任何疑惑可以回復(fù)我~
#2

全民工作狂 提問(wèn)者

require_once('Controller/'.$name.'Controller.class.php'); 換成這個(gè)就打印出Hello World!了!
2015-10-08 回復(fù) 有任何疑惑可以回復(fù)我~
#3

晚安sp 回復(fù) 全民工作狂 提問(wèn)者

嗯,你就是路徑弄錯(cuò)了
2015-10-09 回復(fù) 有任何疑惑可以回復(fù)我~

? ? ??require_once('/test/MVC/Controller/'.$name.'Controller.class.php');這個(gè)的話,確實(shí)寫(xiě)得沒(méi)問(wèn)題嗎?

0 回復(fù) 有任何疑惑可以回復(fù)我~
#1

全民工作狂 提問(wèn)者

-。-真的覺(jué)得這句沒(méi)有問(wèn)題啊……你用你的火眼金睛看看……我已經(jīng)暈了……
2015-09-30 回復(fù) 有任何疑惑可以回復(fù)我~
#2

喬幫主

回復(fù) 全民工作狂你看下它的兩個(gè)提示,都是說(shuō)的你的這個(gè) require_once('/test/MVC/Controller/'.$name.'Controller.class.php');出問(wèn)題了!你再弄下看
2015-09-30 回復(fù) 有任何疑惑可以回復(fù)我~

你還是檢查一下目錄權(quán)限吧。

0 回復(fù) 有任何疑惑可以回復(fù)我~

舉報(bào)

0/150
提交
取消

哪里錯(cuò)了???

我要回答 關(guān)注問(wèn)題
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)