danish sodhi
danish sodhi

Reputation: 1913

How to give STDIN in php without taking STDOUT from a file

How can I give STDIN to a php file from commandline directly ?

Currently I am doing like this : cat test.txt | php myfile.php

and test.txt contains a json object lie this:

{"Name":"XYZ","Age":"25"}

I want to give {"Name":"XYZ","Age":"25"} directly as STDIN with out involving a file, just copy pasting the contests to commandline.

Upvotes: 0

Views: 74

Answers (1)

Saurabh kukade
Saurabh kukade

Reputation: 1634

echo '{"Name":"XYZ","Age":"25"}' |  php myfile.php

Upvotes: 2

Related Questions