【问题标题】:Pthreads doesnt know $_SERVER['DOCUMENT_ROOT']Pthreads 不知道 $_SERVER['DOCUMENT_ROOT']
【发布时间】:2014-12-05 13:28:29
【问题描述】:

我真的需要帮助。我用 pthreads 调用多个函数 .. 一切正常,但我需要在该函数中包含文件,但它不起作用,因为 $_SERVER['DOCUMENT_ROOT'] 在 Thread 中为空。

【问题讨论】:

    标签: pthreads server document-root


    【解决方案1】:

    您可以在脚本文件中的任何位置使用以下内容来确定您的基本路径:

    realpath(dirname(__FILE__))
    

    例子:把这个放在 /srv/www/domain.com/app/config.php 会输出:

    /srv/www/domain.com/app
    

    确保使用“DIRECTORY_SEPARATOR”添加目录斜杠:

    realpath(dirname(__FILE__)).DIRECTORY_SEPARATOR
    

    【讨论】:

    • 这不是我所需要的,但我记得定义常量所以我做到了,但谢谢回答
    猜你喜欢
    • 2013-08-12
    • 2011-12-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-06-01
    • 1970-01-01
    • 2011-11-05
    • 2012-09-28
    相关资源
    最近更新 更多