Open niceboyat opened 2 weeks ago
你试一下 shell_exec 是不是也不好使。 不添加 -f 参数也试试,是否也报错
本项目应该是没有定义 PHP_WIN32 , 因为 windows cygwin 环境下构建,其实是类 linux 环境构建, 这是完整构建配置: https://github.com/swoole/swoole-cli/blob/main/sapi/scripts/cygwin/cygwin-config.sh
windows 原生构建 ,定义 PHP_WIN32 所在文件: https://github.com/php/php-src/blob/php-8.1.27/win32/build/confutils.js#L3227
./buildconf --force
,具体文件: https://github.com/php/php-src/blob/php-8.1.27/buildconf.batbuildconf.bat --f
, 具体文件: https://github.com/php/php-src/blob/php-8.1.27/buildconf.batwindows 构建配置在这个目录: https://github.com/php/php-src/tree/php-8.1.27/win32/build
可定制一下编译参数试试,找到这个文件 https://github.com/swoole/swoole-cli/blob/main/sapi/scripts/cygwin/cygwin-config.sh
添加这一行
export CFLAGS="-DZEND_WIN32=1 "
类似这个,实验一下,看能否解决
看 VCWD_POPEN 函数的定义: 位于 https://github.com/swoole/swoole-cli/tree/main/Zend/zend_virtual_cwd.h 文件
可实验添加的参数 参考: https://github.com/php/php-src/blob/php-8.1.27/win32/build/confutils.js#L3227
export CFLAGS="-DZEND_WIN32=1 -DPHP_WIN32=1 -DWIN32 "
@niceboyat 你试试 不添加 -f 执行,报错吗?
win10下cmd运行:
swoole-cli -f ./test.php
test.php文件代码:
<?php exec('dir', $str, $code); ?>
出现这个错误: