note 96894 added to language.types.string
| From: | gt3 at osu1 dot php dot net | Date: | Sun, 21 Mar 2010 21:06:18 +0000 |
| Subject: | note 96894 added to language.types.string | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-167279@lists.php.net to get a copy of this message | ||
If you try to embed backticks (AKA backquotes) inside of a heredoc, it won't treat the
backticks as a shell command execution operator:
echo <<<_HTML_
<pre>
ls -l</pre>
_HTML_;
the above example will simply output the literal string 'ls -l' rather than running the
command and outputting the results.
To interpolate shell command data you first have to store the returned backtick'd info in
variables, then place the variables inside the heredoc:
$cmd1 = ls -l;
$cmd2 = shell_exec("netstat"); // same thing as backticks
echo <<<_HTML_
<pre>$cmd1 <hr> $cmd2</pre>
_HTML_;
----
Server IP: 69.147.83.197
Probable Submitter: 108.0.31.223
----
Manual Page -- http://www.php.net/manual/en/language.types.string.php
Edit -- https://master.php.net/note/edit/96894
Del: integrated -- https://master.php.net/note/delete/96894/integrated
Del: useless -- https://master.php.net/note/delete/96894/useless
Del: bad code -- https://master.php.net/note/delete/96894/bad+code
Del: spam -- https://master.php.net/note/delete/96894/spam
Del: non-english -- https://master.php.net/note/delete/96894/non-english
Del: in docs -- https://master.php.net/note/delete/96894/in+docs
Del: other reasons-- https://master.php.net/note/delete/96894
Reject -- https://master.php.net/note/reject/96894
Search -- https://master.php.net/manage/user-notes.php