• <bdo id='ZezgL'></bdo><ul id='ZezgL'></ul>

        <tfoot id='ZezgL'></tfoot>

        <i id='ZezgL'><tr id='ZezgL'><dt id='ZezgL'><q id='ZezgL'><span id='ZezgL'><b id='ZezgL'><form id='ZezgL'><ins id='ZezgL'></ins><ul id='ZezgL'></ul><sub id='ZezgL'></sub></form><legend id='ZezgL'></legend><bdo id='ZezgL'><pre id='ZezgL'><center id='ZezgL'></center></pre></bdo></b><th id='ZezgL'></th></span></q></dt></tr></i><div id='ZezgL'><tfoot id='ZezgL'></tfoot><dl id='ZezgL'><fieldset id='ZezgL'></fieldset></dl></div>
        <legend id='ZezgL'><style id='ZezgL'><dir id='ZezgL'><q id='ZezgL'></q></dir></style></legend>

        <small id='ZezgL'></small><noframes id='ZezgL'>

        相对路径在 cron PHP 脚本中不起作用

        Relative path not working in cron PHP script(相对路径在 cron PHP 脚本中不起作用)

          <bdo id='7CwmM'></bdo><ul id='7CwmM'></ul>
            <tfoot id='7CwmM'></tfoot>
              <tbody id='7CwmM'></tbody>

            <small id='7CwmM'></small><noframes id='7CwmM'>

            <legend id='7CwmM'><style id='7CwmM'><dir id='7CwmM'><q id='7CwmM'></q></dir></style></legend>

                • <i id='7CwmM'><tr id='7CwmM'><dt id='7CwmM'><q id='7CwmM'><span id='7CwmM'><b id='7CwmM'><form id='7CwmM'><ins id='7CwmM'></ins><ul id='7CwmM'></ul><sub id='7CwmM'></sub></form><legend id='7CwmM'></legend><bdo id='7CwmM'><pre id='7CwmM'><center id='7CwmM'></center></pre></bdo></b><th id='7CwmM'></th></span></q></dt></tr></i><div id='7CwmM'><tfoot id='7CwmM'></tfoot><dl id='7CwmM'><fieldset id='7CwmM'></fieldset></dl></div>

                  本文介绍了相对路径在 cron PHP 脚本中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  如果 PHP 脚本作为 cron 脚本运行,如果使用相对路径,则包含通常会失败.例如,如果您有

                  If a PHP script is run as a cron script, the includes often fail if relative paths are used. For example, if you have

                  require_once('foo.php');
                  

                  在命令行上运行时会找到文件 foo.php,但在从 cron 脚本运行时不会找到.

                  the file foo.php will be found when run on the command line, but not when run from a cron script.

                  对此的典型解决方法是先将 chdir 指向工作目录,或使用绝对路径.但是,我想知道导致这种行为的 cron 和 shell 之间有什么不同.为什么在 cron 脚本中使用相对路径会失败?

                  A typical workaround for this is to first chdir to the working directory, or use absolute paths. I would like to know, however, what is different between cron and shell that causes this behavior. Why does it fail when using relative paths in a cron script?

                  推荐答案

                  从 cron 运行时,脚本的工作目录可能不同.此外,关于 PHP 的 require() 和 include() 存在一些混淆,这导致了工作目录真正是问题所在的混淆:

                  The working directory of the script may be different when run from a cron. Additionaly, there was some confusion about PHPs require() and include(), which caused confusion about the working directory really being the problem:

                  include('foo.php') // searches for foo.php in the same directory as the current script
                  include('./foo.php') // searches for foo.php in the current working directory
                  include('foo/bar.php') // searches for foo/bar.php, relative to the directory of the current script
                  include('../bar.php') // searches for bar.php, in the parent directory of the current working directory
                  

                  这篇关于相对路径在 cron PHP 脚本中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  DeepL的翻译效果还是很强大的,如果我们要用php实现DeepL翻译调用,该怎么办呢?以下是代码示例,希望能够帮到需要的朋友。 在这里需要注意,这个DeepL的账户和api申请比较难,不支持中国大陆申请,需要拥有香港或者海外信用卡才行,没账号的话,目前某宝可以
                  PHP通过phpspreadsheet导入Excel日期,导入系统后,全部变为了4开头的几位数字,这是为什么呢?原因很简单,将Excel的时间设置问文本,我们就能看到该日期本来的数值,上图对应的数值为: 要怎么解决呢?进行数据转换就行,这里可以封装方法,或者用第三方的
                  mediatemple - can#39;t send email using codeigniter(mediatemple - 无法使用 codeigniter 发送电子邮件)
                  Laravel Gmail Configuration Error(Laravel Gmail 配置错误)
                  Problem with using PHPMailer for SMTP(将 PHPMailer 用于 SMTP 的问题)
                  Issue on how to setup SMTP using PHPMailer in GoDaddy server(关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题)

                      <small id='jZkFT'></small><noframes id='jZkFT'>

                    1. <legend id='jZkFT'><style id='jZkFT'><dir id='jZkFT'><q id='jZkFT'></q></dir></style></legend>
                        <tbody id='jZkFT'></tbody>
                      <tfoot id='jZkFT'></tfoot>
                      • <bdo id='jZkFT'></bdo><ul id='jZkFT'></ul>
                        • <i id='jZkFT'><tr id='jZkFT'><dt id='jZkFT'><q id='jZkFT'><span id='jZkFT'><b id='jZkFT'><form id='jZkFT'><ins id='jZkFT'></ins><ul id='jZkFT'></ul><sub id='jZkFT'></sub></form><legend id='jZkFT'></legend><bdo id='jZkFT'><pre id='jZkFT'><center id='jZkFT'></center></pre></bdo></b><th id='jZkFT'></th></span></q></dt></tr></i><div id='jZkFT'><tfoot id='jZkFT'></tfoot><dl id='jZkFT'><fieldset id='jZkFT'></fieldset></dl></div>