<?php fwrite(STDOUT, "Please enter your namen");
// Read the input
$name = fgets(STDIN);
fwrite(STDOUT, "Hello $name");
// Exit correctly
exit(0);
?>
echo " hello world " | php stdin.php
result hello world
//$stdin = fopen('php://stdin', 'r');
$stdin=stream_get_contents(STDIN);
echo $stdin;
?>
Other method
<?php
echo " This is the result $argv[1]";
?>
a=$(echo 'ambiorix') | php cmd.php $a
This is the result ambiorix
No hay comentarios:
Publicar un comentario