Page 1 of 1

how to give a commandline arguement

Posted: Fri Nov 07, 2008 12:17 am
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?

Re: how to give a commandline arguement

Posted: Fri Nov 07, 2008 12:39 am
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.