note 10408 deleted from function.fopen by sander

From: Date: Sun, 07 Apr 2002 11:10:48 +0000
Subject: note 10408 deleted from function.fopen by sander
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-28821@lists.php.net to get a copy of this message
Hi there! For anyone wondering how to use php for console scripts, here it goes a function that reads stdin and works like good old Pascal Readln(). Hope it helps. Paulo <? Function Readln(&$INPUT){ $fp = fopen("php://stdin","r"); while (!feof($fp)) { $BUFFER = fgetc($fp); $INPUT .= $BUFFER; if ($BUFFER == "\n") break; } fclose($fp); } echo "Enter something:"; Readln($UserInput); echo "Input from console: ".$UserInput; ?>

« previous php.notes (#28821) next »