note 34237 modified in features.commandline by danbrown

From: Date: Tue, 25 Nov 2008 15:51:06 +0000
Subject: note 34237 modified in features.commandline by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-146925@lists.php.net to get a copy of this message
You can use this function to ask user to enter something. <?php function read ($length='255') { if (!isset ($GLOBALS['StdinPointer'])) { $GLOBALS['StdinPointer'] = fopen ("php://stdin","r"); } $line = fgets ($GLOBALS['StdinPointer'],$length); return trim ($line); } // then echo "Enter your name: "; $name = read (); echo "\nHello $name! Where you came from? "; $where = read (); echo "\nI see. $where is very good place."; ?> --was-- You can use this function to ask user to enter smth <? function read ($length='255') { if (!isset ($GLOBALS['StdinPointer'])) { $GLOBALS['StdinPointer'] = fopen ("php://stdin","r"); } $line = fgets ($GLOBALS['StdinPointer'],$length); return trim ($line); } // then echo "Enter your name: "; $name = read (); echo "\nHello $name! Where you came from? "; $where = read (); echo "\nI see. $where is very good place."; ?> http://php.net/manual/en/features.commandline.php

« previous php.notes (#146925) next »