PHP from command line

Run a php script in-line on cli like this:

php -r 'print "hello world";'

Execute a file:

php -f script-name.php

Running php from the command line means you can do real cool stuff like:

How to find your php.ini file

php -r 'phpinfo();' | grep php.ini

This will return the location of your php.ini file.

Or alternatively you can use the info option:

php -i




Post new comment

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

More information about formatting options