note 26174 rejected from features.commandline by nicos
| From: | nicos@php.net | Date: | Mon, 21 Oct 2002 14:26:32 +0000 |
| Subject: | note 26174 rejected from features.commandline by nicos | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-38366@lists.php.net to get a copy of this message | ||
If you are trying to set up an interactive command line script and you want to get started straight
away (works on 4+ I hope). Here is some code to start you off:
<?php
// Stop the script giving time out errors..
set_time_limit(0);
// This opens standard in ready for interactive input..
define('STDIN',fopen("php://stdin","r"));
// Main event loop to capture top level command..
while(!0)
{
// Print out main menu..
echo "Select an option..\n\n";
echo " 1) Do this\n";
echo " 2) Do this\n";
echo " 3) Do this\n";
echo " x) Exit\n";
// Decide what menu option to select based on input..
switch(trim(fgets(STDIN,256)))
{
case 1:
break;
case 2:
break;
case 3:
break;
case "x":
exit();
default:
break;
}
}
// Close standard in..
fclose(STDIN);
?>