How do you run a PHP script from the command line?

PHP: How do you run a PHP script from the command line?

Just run php your-file.php.

php your_file.php

And it will execute the PHP file.

webdevetc profile pic
webdevetc

I am a 29 year old backend web developer from London, mostly focusing on PHP and Laravel lately. This (webdevetc.com) is my blog where I write about some web development topics (PHP, Laravel, Javascript, and some server stuff). contact me here.



More...


Comments and discussion about How do you run a PHP script from the command line?

Found this interesting? Maybe you want to read some more in this series?

Or see other topics in the PHP language

Or see other languages/frameworks:
PHP Laravel Composer Apache CentOS and Linux Stuff WordPress General Webdev and Programming Stuff JavaScript
Or see random questions

How to check if two strings are anagrams in PHP?

How to block IP addresses in Apache by using regular expressions (regex) in .htaccess

How to add a name prefix to all routes in a group?

How to Extract Query String (from a URL) Into an Associative Array in PHP

How to block access to certain referrers in Apache using .htaccess

How to see all of the options for an artisan command?

What is the difference between integration and unit tests?

How to add comments in PHP

How to find out what version of Laravel you are using?

How to add the CSRF (Cross-site request forgery) token in Laravel?