doute7910 2014-01-14 10:53
浏览 82
已采纳

PHP - 无法在shutdown函数中找到文件

I'm trying to set up some error logging

register_shutdown_function('shutdown');

but whenever I try to include a file inside of the shutdown function - it cannot be found, even though it exists and is included just fine throughout my application elsewhere

function shutdown()
{
    require_once LIB_DIR.'phpmailer/class.phpmailer.php';
}

Gives me an error saying the file could not be found.. am I missing something here, does the relative path to a file change inside the shutdown function or something?

  • 写回答

3条回答 默认 最新

  • dongmengan8620 2014-01-14 11:15
    关注

    One of your comments suggest you're using a relative path:

    ../web-app/app/libraries/phpmailer/class.phpmailer.php
    ^^
    

    That's generally unreliable in the PHP universe but in this particular case:

    Working directory of the script can change inside the shutdown function under some web servers, e.g. Apache.

    If the error message doesn't display the full path, you can at least print current directory yourself for debugging purposes:

    var_dump(getcwd());
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 C++ 头文件/宏冲突问题解决
  • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
  • ¥50 安卓adb backup备份子用户应用数据失败
  • ¥20 有人能用聚类分析帮我分析一下文本内容嘛
  • ¥15 请问Lammps做复合材料拉伸模拟,应力应变曲线问题
  • ¥30 python代码,帮调试
  • ¥15 #MATLAB仿真#车辆换道路径规划
  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建
  • ¥15 数据可视化Python
  • ¥15 要给毕业设计添加扫码登录的功能!!有偿