note 10408 added to fopen

From: Date: Tue, 02 Jan 2001 14:41:04 +0000
Subject: note 10408 added to fopen
Groups: php.notes 
Request: Send a blank email to php-notes+get-9246@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; ?> http://www.php.net/manual/function.fopen.php

« previous php.notes (#9246) next »