Writing scripts that run from command line is sometimes useful. It gives us more flexibility rather than scripts that called from web browsers. But passing parameters to these scripts is a little different. They don't recognize GET and POST variables, so you can't pass GET and POST variables to these script.
The good news, reading command line arguments is very easy! Let's see an example. Suppose you are writing an image downloader script that takes four arguments: the website, the file type to download, the username and pasword to login to the site. You run the script by calling it from command line like this:
php imgdownloader.php -U http://www.bikini.com/todaypics.html -u u4523 -p secret -t jpg
The command above will tell your script login to http://www.bikini.com as user u4523 and supply secret for the password, then download all jpeg images from todaypics.html. Here's how to read the arguments from your script:
Listing 1: imgdownloader.php
| Tel. | +62 31 8662872 +62 856 338 6017 |
| ICQ | 489571630 |
| Skype | dede_bl4ckheart |
| Yahoo | dede_bl4ckheart |
| nashruddin.amin |