There may be times when you want to read from STDIN to a PHP script you’ve created from the command line. Code below: $in = fopen(‘php://stdin’, ‘r’); while(!feof($in)){ $text = $text . fgets($in, 4096); } What this will do is read from STDIN, and create a $text variable of the contents. It does this …
Continue reading “Reading STDIN to PHP from the Command Line (CLI)”