Command Line arguments

I am using php as a scripting language (rather that for web purposes), and would like to be able to pass arguments via the command line. Is this possible? Right now I can use php “include(myscript.php”); myfunction($myvar);" but it’s a little messier than I would like. Is there any other way?

Thanks in advance,

You create your “Scripts” just like if you were doing a web page, however, you when you want to “Launch” it you call it like so:

php my_script.php
php -f my_script.php

You can refer to for more help as well.

Example #8 provides an excellent example of how to use command-line parameters in PHP-CLI.

Sponsor our Newsletter | Privacy Policy | Terms of Service