<legend id='Mg6oR'><style id='Mg6oR'><dir id='Mg6oR'><q id='Mg6oR'></q></dir></style></legend>
        <bdo id='Mg6oR'></bdo><ul id='Mg6oR'></ul>

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

      1. <i id='Mg6oR'><tr id='Mg6oR'><dt id='Mg6oR'><q id='Mg6oR'><span id='Mg6oR'><b id='Mg6oR'><form id='Mg6oR'><ins id='Mg6oR'></ins><ul id='Mg6oR'></ul><sub id='Mg6oR'></sub></form><legend id='Mg6oR'></legend><bdo id='Mg6oR'><pre id='Mg6oR'><center id='Mg6oR'></center></pre></bdo></b><th id='Mg6oR'></th></span></q></dt></tr></i><div id='Mg6oR'><tfoot id='Mg6oR'></tfoot><dl id='Mg6oR'><fieldset id='Mg6oR'></fieldset></dl></div>
        <tfoot id='Mg6oR'></tfoot>
      2. 如何在没有shell访问的情况下获取php解释器/二进制文件的完整路径

        How to get the full path to php interpreter / binary without shell access(如何在没有shell访问的情况下获取php解释器/二进制文件的完整路径)
      3. <small id='ZmRqT'></small><noframes id='ZmRqT'>

          <tbody id='ZmRqT'></tbody>
        <legend id='ZmRqT'><style id='ZmRqT'><dir id='ZmRqT'><q id='ZmRqT'></q></dir></style></legend>

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

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

                1. <tfoot id='ZmRqT'></tfoot>

                  本文介绍了如何在没有shell访问的情况下获取php解释器/二进制文件的完整路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  如何从 php 脚本中获取 php 解释器的完整路径(无命令行访问权限).

                  我需要做的是:

                  $foo = "/usr/bin/php";回声 $foo;

                  但我需要先获取路径,以便将其分配给 foo.

                  如果您有一个在 Windows 和 nix 上都可以运行的更好的解决方案,但如果没有,nix 会很好.

                  在你问之前,

                  1. 问主人是不可能的
                  2. 没有外壳访问

                  问题是使用它输出的任何东西都不起作用.例如 PHP_BINDIR 将输出/usr/bin 但使用/usr/bin/php 无济于事.完整代码为:

                  exec("php-cli $path_to_file >/dev/null 2>/dev/null &");

                  但即使使用/usr/bin/php-cli 也不起作用,即使它告诉我.我必须使用:

                  exec("/opt/php52/bin/php-cli $path_to_file >/dev/null 2>/dev/null &");

                  例如对于这个特定的主机.

                  解决方案

                  你可以用这个常量找到 PHP 二进制路径:

                  PHP_BINDIR

                  从 PHP 5.4 开始,您可以使用此常量获取当前实际运行的可执行文件的路径:

                  PHP_BINARY

                  http://php.net/manual/en/reserved.constants.php

                  How can I get the full path to php interpreter from a php script (no command line access).

                  What I need to do is:

                  $foo = "/usr/bin/php";
                  echo $foo;
                  

                  But I need to get the path first so I can assign it to foo.

                  If you have a solution that works on both Windows and nix even better but if not, nix would be fine.

                  Before you ask,

                  1. Asking the host is out of the question
                  2. No shell access

                  The problem is that using whatever it outputs doesn't work. For example PHP_BINDIR will output /usr/bin but using /usr/bin/php won't help. The full code is:

                  exec("php-cli $path_to_file > /dev/null 2>/dev/null &"); 
                  

                  But even using the /usr/bin/php-cli doesn’t work even though it tells me that. I have to use:

                  exec("/opt/php52/bin/php-cli $path_to_file > /dev/null 2>/dev/null &");
                  

                  For this particular host for example.

                  解决方案

                  You can find the PHP binary path with this constant:

                  PHP_BINDIR
                  

                  As of PHP 5.4, you can get the path to the executable actually running currently with this constant:

                  PHP_BINARY
                  

                  http://php.net/manual/en/reserved.constants.php

                  这篇关于如何在没有shell访问的情况下获取php解释器/二进制文件的完整路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  Is PHP or PHP based web framework stateful or stateless?(PHP 或基于 PHP 的 Web 框架是有状态的还是无状态的?)
                  How to parse django style template tags(如何解析 django 样式模板标签)
                  What is a good setup for editing PHP in Emacs?(在 Emacs 中编辑 PHP 的好设置是什么?)
                  How to check whether specified PID is currently running without invoking ps from PHP?(如何在不从 PHP 调用 ps 的情况下检查指定的 PID 当前是否正在运行?)
                  What#39;s the difference between escapeshellarg and escapeshellcmd?(escapeshellarg 和escapeshellcmd 有什么区别?)
                  php in background exec() function(php 后台 exec() 函数)

                2. <legend id='AG6ha'><style id='AG6ha'><dir id='AG6ha'><q id='AG6ha'></q></dir></style></legend>
                      <tbody id='AG6ha'></tbody>

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

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

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

                          1. <tfoot id='AG6ha'></tfoot>