note 120738 added to ref.exec

From: Date: Sat, 04 Mar 2017 12:35:29 +0000
Subject: note 120738 added to ref.exec
Groups: php.notes 
Request: Send a blank email to php-notes+get-208870@lists.php.net to get a copy of this message
Just following up my previous post, in reply to lancelot--du-lac at hotmail dot fr: The behaviour described was fixed in PHP 5.3 in the following commit: https://github.com/php/php-src/commit/19322fc782af429938da8d3b421c0807cf1b848a#diff-15f2d3ef68f383a87cce668765721041R221 To replicate the fix in your own code, so it also runs on PHP 5.2, instead of: <?php $cmd = "...any shell command, maybe with multiple quotes..."; exec($cmd); ?> use <?php $cmd = "...any shell command, maybe with multiple quotes..."; if (strtoupper(substr(php_uname('s'), 0, 3)) == "WIN" && version_compare(PHP_VERSION, "5.3", "<")) { $cmd = '"' . $cmd . '"'; } exec($cmd); ?> This replicates the behaviour of PHP 5.3 and above. Note that this applies to all shell commands (not just exec(), as used in my example). ---- Server IP: 72.52.91.14 Probable Submitter: 212.69.47.82 ---- Manual Page -- http://php.net/manual/en/ref.exec.php Edit -- https://master.php.net/note/edit/120738 Del: integrated -- https://master.php.net/note/delete/120738/integrated Del: useless -- https://master.php.net/note/delete/120738/useless Del: bad code -- https://master.php.net/note/delete/120738/bad+code Del: spam -- https://master.php.net/note/delete/120738/spam Del: non-english -- https://master.php.net/note/delete/120738/non-english Del: in docs -- https://master.php.net/note/delete/120738/in+docs Del: other reasons-- https://master.php.net/note/delete/120738 Reject -- https://master.php.net/note/reject/120738 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#208870) next »