Home >Backend Development >PHP Tutorial >python - php如何在命令行指定search path?

python - php如何在命令行指定search path?

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-06 20:11:501042browse

比如python,在命令行敲python -h会有

<code>Other environment variables:
PYTHONPATH   : ':'-separated list of directories prefixed to the
               default module search path.  The result is sys.path.
</code>

也就是PYTHONPATH设置了的话,相当于python要运行的文件会在相应目录搜索。

所以对于PHP有没相应的功能?


我用ProcessBuilder,这样它能找到zip文件中的php文件

<code>List commands = new java.util.ArrayList<string>();
commands.add("python");
commands.add("-m");
commands.add("test");//test.py is in test.zip
ProcessBuilder pb = new ProcessBuilder();
pb.command(commands);
Map workerEnv = pb.environment();
workerEnv.put("PYTHONPATH", "/path/to/test.zip");//可见PYTHONPATH设置了,就相当于java里的-cp设置了
Process worker = pb.start();
</string></code>

如果用ProcessBuilder传入这个environment,怎么做?
以致能够在让ProcessBuilder运行zip文件中的PHP文件?
非常感谢!

回复内容:

比如python,在命令行敲python -h会有

<code>Other environment variables:
PYTHONPATH   : ':'-separated list of directories prefixed to the
               default module search path.  The result is sys.path.
</code>

也就是PYTHONPATH设置了的话,相当于python要运行的文件会在相应目录搜索。

所以对于PHP有没相应的功能?


我用ProcessBuilder,这样它能找到zip文件中的php文件

<code>List commands = new java.util.ArrayList<string>();
commands.add("python");
commands.add("-m");
commands.add("test");//test.py is in test.zip
ProcessBuilder pb = new ProcessBuilder();
pb.command(commands);
Map workerEnv = pb.environment();
workerEnv.put("PYTHONPATH", "/path/to/test.zip");//可见PYTHONPATH设置了,就相当于java里的-cp设置了
Process worker = pb.start();
</string></code>

如果用ProcessBuilder传入这个environment,怎么做?
以致能够在让ProcessBuilder运行zip文件中的PHP文件?
非常感谢!

通过在php.ini中的include_path配置或者使用set_include_path函数就能设置。

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn