note 26174 added to features.commandline

From: Date: Mon, 21 Oct 2002 14:20:11 +0000
Subject: note 26174 added to features.commandline
Groups: php.notes 
Request: Send a blank email to php-notes+get-38364@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); ?> -- http://www.php.net/manual/en/features.commandline.php http://master.php.net/manage/user-notes.php?action=edit+26174 http://master.php.net/manage/user-notes.php?action=delete+26174 http://master.php.net/manage/user-notes.php?action=reject+26174

« previous php.notes (#38364) next »