BRADERY Posted January 30, 2011 Share Posted January 30, 2011 So say I have a script, it calls for a text file in the script. Instead of putting the name of the text file is there a way I can run the script then type the name of the file in the CLI? Quote Link to comment https://forums.phpfreaks.com/topic/226096-php-script-in-cli-with-user-imput/ Share on other sites More sharing options...
.josh Posted January 30, 2011 Share Posted January 30, 2011 You can use $_SERVER['argv'] to get arguments passed. Example: CLI: php.exe script.php filename.txt script.php print_r($_SERVER['argv']); output: Array ( [0] => script.php [1] => filename.txt ) Quote Link to comment https://forums.phpfreaks.com/topic/226096-php-script-in-cli-with-user-imput/#findComment-1167165 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.