gpt4 book ai didi

PHP CLI : what directory?

转载 作者:行者123 更新时间:2023-12-03 23:57:27 28 4
gpt4 key购买 nike

我有一个从/执行的 php cli 脚本,但该脚本位于/opt/script/script.php。如何从脚本中获取脚本的动态位置

$location = ... (Get the location of the script) 
echo $location == '/opt/script' ? 'YAY' : 'Stupid';

输出

YAY

那种东西。

最佳答案

dirname(__FILE__) (或较新版本中的 __DIR__ )应该足够了。您可以在 Magic Constants 找到更多引用。章节。

关于PHP CLI : what directory?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7627735/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com