It is possible to pipe data using unix pipes into a command-line php script? I've tried
$> data | php script.php
But the expected data
did not show up in $argv
. Is there a way to do this?
It is possible to pipe data using unix pipes into a command-line php script? I've tried
$> data | php script.php
But the expected data
did not show up in $argv
. Is there a way to do this?
Best option is to use -r option and take the data from the stdin. Ie I use it to easily decode JSON using PHP. This way you don't have to create physical script file.
It goes like this:
This piece of code will display shared folders between host & a container. Please replace $1 by the container name or put it in a bash alias like ie displayshares() { ... }
You can pipe data in, yes. But it won't appear in
$argv
. It'll go to stdin. You can read this several ways, includingfopen('php://stdin','r')
There are good examples in the manual