how to give a commandline arguement

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
susrisha
Forum Contributor
Posts: 439
Joined: Thu Aug 07, 2008 11:43 pm
Location: Hyderabad India

how to give a commandline arguement

Post by susrisha »

i have a got a program which reads about 30 lines from last of another file and so on..

My problem now is :
I want to give the number of lines as an arguement and not as a constant.

the basic command to run the file is

Code: Select all

 
php -f  filename
 
For a c program the command will be a space separated by arguements ..
what is it for a php program?
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: how to give a commandline arguement

Post by requinix »

It's exactly the same.

Add the arguments after the file name; $argc and $argv are what you would expect ($argv[0] is the filename, not the full "php -f filename").
If the arguments are valid flags to php (like -h or -l) then you need a -- between the file and the arguments.
Post Reply