【问题标题】:file-exists check for php's auto_prepend_file文件存在检查 php 的 auto_prepend_file
【发布时间】:2012-10-27 15:57:24
【问题描述】:

我目前的情况是,在我的vhost.conf 中有一个条目可以自动包含一个文件以开始分析:

php_value auto_prepend_file /home/xhprof/include/xhprof.php

这个东西在 SVN 中,可能会被系统上没有安装 xhprof 的人检出。结果是,xhprof.php 没有找到,PHP 抛出一个错误。

有谁知道,是否有可能在包含之前检查该文件是否存在?

提前谢谢 :)

【问题讨论】:

    标签: php apache2 vhosts


    【解决方案1】:

    这样做:

    fileX.php:

    if(is_file("/home/xhprof/include/xhprof.php")){ include '/home/xhprof/include/xhprof.php'; }

    vhost.conf:

    php_value auto_prepend_file path/to/fileX.php

    有一个函数叫做:is_file()

    【讨论】:

    • 谢谢我已经考虑过类似的解决方案,但这不是很有用,因为你必须将此文件添加到所有可能使用分析的项目中。我刚刚想到的是类似于 shell 的条目,例如我的 vhost.conf 的 <if exists [filename]>,但我还找不到这样的东西
    猜你喜欢
    • 2014-09-06
    • 2016-06-29
    • 2023-01-02
    • 2023-04-04
    • 1970-01-01
    • 2011-05-14
    • 1970-01-01
    • 2012-04-18
    • 2020-05-23
    相关资源
    最近更新 更多