【问题标题】:Fatal error: require_once(): Failed opening required file.php致命错误:require_once(): 无法打开所需的 file.php
【发布时间】:2014-01-16 15:22:57
【问题描述】:

我有一个在我的本地机器上运行的网站。当我在 OSX 上时,这些行没问题。而在 Windows 上会产生错误:

set_include_path ( get_include_path () . ':' . dirname ( __FILE__ ) . '/../lib/propel/runtime/lib/' );
set_include_path ( get_include_path () . ':' . dirname ( __FILE__ ) . '/../lib/smarty/libs/' );
set_include_path ( get_include_path () . ':' . dirname ( __FILE__ ) . '/../classes/' );
set_include_path ( get_include_path () . ':' . dirname ( __FILE__ ) . '/../classes/ORM/' );

这是错误

致命错误:require_once(): 未能打开所需的“Propel.php” (include_path='.:C:/wamp/www/emporio-rossi/conf/:C:\wamp\www\emporio-rossi\wapp/../lib/propel/runtime/lib/:C:\wamp\ www\emporio-rossi\wapp/../lib/smarty/libs/:C:\wamp\www\emporio-rossi\wapp/../classes/:C:\wamp\www\emporio-rossi\wapp/ ../类/ORM/') 在 C:\wamp\www\emporio-rossi\wapp\conf.inc.php 第 33 行

Propel.php 位于第一个 URI (set_include_path ( get_include_path () . ':' . dirname ( __FILE__ ) . '/../lib/propel/runtime/lib/' );)

【问题讨论】:

    标签: php path set-include-path


    【解决方案1】:

    Windows 使用 ; 作为路径分隔符,而 nix(包括 OSX)使用 :

    答案是使用PATH_SEPARATOR 常量:

    set_include_path ( get_include_path () . PATH_SEPARATOR . dirname ( __FILE__ ) . '/../lib/propel/runtime/lib/' );
    

    来自the docs

    使用 PATH_SEPARATOR 常量,可以扩展包含路径而不管操作系统。

    【讨论】:

      猜你喜欢
      • 2019-08-10
      • 2015-04-10
      • 2016-02-07
      • 1970-01-01
      • 1970-01-01
      • 2014-10-21
      • 2016-07-06
      相关资源
      最近更新 更多