Re: [PHP] Can PHP take input from the command prompt interactively?

2001-11-25 Thread Dan McCullough

An example for ya

#!/usr/local/bin/php -q
?php
/*
file name: shellexample.php
created by:  dan mccullough
date created: 10/26/01
purpose:  just to do a simple shell script that takes the input and places its output 
on the
screen

For more information contact Dan McCullough at 603.444.9808

To use this on the command line type [root@ns web]# php shellexample.php
then type your line of text.
*/
function read() {
$fp=fopen(/dev/stdin, r);
$input=fgets($fp, 255);
fclose($fp);

return $input;
}

print(Please input your text? );
$input = read();
$string = $input;
$string = preg_replace (/(.)/, \\1\n, $string);
print ($string);

?

--- David Yee [EMAIL PROTECTED] wrote:
 Can I write a command line PHP script like the following:
 
 php -q test.php
 
 Output: 
 
 ==
 1)choice A
 2)choice B
 3)choice C
 
 Please enter an option: 1
 ==
 
 Thanks.
 
 David
 
 
 


=
Dan McCullough
---
Theres no such thing as a problem unless the servers are on fire!
h: 603.444.9808
w: McCullough Family
w: At Work

__
Do You Yahoo!?
Yahoo! GeoCities - quick and easy web site hosting, just $8.95/month.
http://geocities.yahoo.com/ps/info1

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Can PHP take input from the command prompt interactively?

2001-11-24 Thread Evan Nemerson

Yes. you can fopen php://stdin




On Saturday 24 November 2001 06:29 pm, you wrote:
 Can I write a command line PHP script like the following:

 php -q test.php

 Output:

 ==
 1)choice A
 2)choice B
 3)choice C

 Please enter an option: 1
 ==

 Thanks.

 David

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]