Bug #74074 [Opn->Nab]: "||" is not useful on windows's program execution function.

From: Date: Wed, 15 Feb 2017 17:33:10 +0000
Subject: Bug #74074 [Opn->Nab]: "||" is not useful on windows's program execution function.
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-207392@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=74074&edit=1 ID: 74074 Updated by: ab@php.net Reported by: phith0n dot ph2f at gmail dot com Summary: "||" is not useful on windows's program execution function. -Status: Open +Status: Not a bug Type: Bug Package: Program Execution Operating System: Windows PHP Version: 5.6.30 Block user comment: N Private report: N New Comment: Thanks for the report. Your assumption doesn't sound correct. "A || B" is the exact construct, so then "if A fails, execute B". The fact that the concrete call to whoami doesn't give an output is rather because it's invoked from a process, possibly impersonated, started by IIS. If the exact issue is whoami, you might want to switch to get_current_user() for more compatibility. Otherwise - the difference to CLI mentioned is influenced by the environment where some command is executed. Thanks. Previous Comments: ------------------------------------------------------------------------ [2017-02-10 11:14:57] phith0n dot ph2f at gmail dot com Description: ------------ I use iis7.0 && php5.6.30(I also test in apache+php, the result is same) to run following php code ``` <?php $cmd = "error_command || whoami"; exec($cmd, $output, $return_val); var_dump($output); var_dump($return_val); ?> ``` If the first command is wrong, then the second command wouldn't be executed, the output is ``` array(0) { } int(1) ``` But I run the code on windows+built-in webserver, the output is ``` array(1) { [0]=> string(12) "71ec\phithon" } int(0) ``` Cli's result: ``` F:\PHPStudy\WWW>F:\soft\php-5.6.30-Win32-VC11-x86\php.exe test\a.php 'error_command' 不是内部或外部命令,也不是可运行的程序 或批处理文件。 array(1) { [0]=> string(12) "71ec\phithon" } int(0) ``` So why php has 2 different results? Test script: --------------- <?php $cmd = "error_command || whoami"; exec($cmd, $output, $return_val); var_dump($output); var_dump($return_val); ?> Expected result: ---------------- array(1) { [0]=> string(12) "71ec\phithon" } int(0) Actual result: -------------- array(0) { } int(1) ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=74074&edit=1

« previous php.bugs (#207392) next »