Warning: require_once(../models/Message.php) [function.require-once]: failed to open stream: No such

Warning: require_once(../models/Message.php) [function.require-once]: failed to open stream: No such file or directory in F:\xampp\htdocs\zendfrm\application\controllers\IndexController.php on line 2
Call Stack
#TimeMemoryFunctionLocation
10.0029340224{main}( )..\index.php:0
20.03902197240Zend_Application->run( )..\index.php:26
30.03902197240Zend_Application_Bootstrap_Bootstrap->run( ) ..\Application.php:366
40.03912197296Zend_Controller_Front->dispatch( ???, ??? ) ..\Bootstrap.php:97
50.05093507920Zend_Controller_Dispatcher_Standard->dispatch( object(Zend_Controller_Request_Http)[14],object(Zend_Controller_Response_Http)[15] ) ..\Front.php:954
60.05153507976Zend_Controller_Dispatcher_Standard->loadClass( string(15) ) ..\Standard.php:262
70.05263526248include_once( 'F:\xampp\htdocs\zendfrm\application\controllers\IndexController.php' ) ..\Standard.php:344

( ! ) Fatal error: require_once() [function.require]: Failed opening required '../models/Message.php' (include_path='F:\xampp\htdocs\zendfrm\application/../library;F:\xampp\htdocs\zendfrm\library;.;F:\xampp\php\PEAR') in F:\xampp\htdocs\zendfrm\application\controllers\IndexController.php on line 2

Call Stack

#

Time

Memory

Function

Location

1

0.0029

340224

{main}( )

..\index.php:0

2

0.0390

2197240

Zend_Application->run( )

..\index.php:26

3

0.0390

2197240

Zend_Application_Bootstrap_Bootstrap->run( )

..\Application.php:366

4

0.0391

2197296

Zend_Controller_Front->dispatch( ???, ??? )

..\Bootstrap.php:97

5

0.0509

3507920

Zend_Controller_Dispatcher_Standard->dispatch( object(Zend_Controller_Request_Http)[14],object(Zend_Controller_Response_Http)[15] )

..\Front.php:954

6

0.0515

3507976

Zend_Controller_Dispatcher_Standard->loadClass( string(15) )

..\Standard.php:262

7

0.0526

3526248

include_once( 'F:\xampp\htdocs\zendfrm\application\controllers\IndexController.php' )

..\Standard.php:344

直接用require_once '../models/Message.php';  报错
//此方法能解决路径不对的错误
 方法1   require_once  dirname(dirname(__FILE__)).'/models/Message.php';

方法2   require_once APPLICATION_PATH.'/models/Message.php';

原因如下:

echo __FILE__ ; // 取得当前文件的绝对地址,结果:D:\www\test.php

echo dirname(__FILE__); // 取得当前文件所在的绝对目录,结果:D:\www\

echo dirname(dirname(__FILE__)); //取得当前文件的上一层目录名,结果:D:\

 

 

<?php
require_once '../models/Message.php';
//此方法能解决路径不对的错误
 //require_once  dirname(dirname(__FILE__)).'/models/Message.php';
class IndexController extends Zend_Controller_Action
{
//这是初始化函数
    public function init()
    {
        /* Initialize action controller here */
     
     file_put_contents("d:/mylog.txt", __FILE__.date('y-m-d h:i:s')."init..\r\n",FILE_APPEND);
    }

    //控制器中的一个函数
    public function indexAction()
    {
        // action body
        file_put_contents("d:/mylog.txt", __FILE__.date('y-m-d h:i:s')."index..\r\n",FILE_APPEND);
        //如果什么都没有些,相当于有以下一句话;用view/scripts/index/index.phtml
        $messageModel=new Message();
        $res=$messageModel->fetchAll();
        echo '<pre>';
        print_r($res);
        echo '</pre>';
       
        $this->render('index');
    }

 public function testAction(){
 }
}

 

 

 

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值