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 block an IP address in .htaccess

How to generate an array for a dropdown (with ['key' => 'value']) suitable for a dropdown, from a Laravel collection of Eloquent objects?

How to set up an alias to map one directory to another destination

How to return an item in Eloquent, or throw a ModelNotFoundException exception if it isn't found?

How to block IPv6 IP addresses in .htaccess

What are some ways you can log debug messages and data in JS?

What are the predefined variables in PHP?

How to make multiple routes share the same URL structure or URL parameters

How to find an item by Primary Key in Eloquent, or throw a ModelNotFoundException exception if it isn't found?

What is YAGNI?