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 Enable Directory Listings in Apache with .htaccess

How to replace whitespace with a single space

What is an example of an object literal?

How do you launch the PHP interactive shell?

What are generators in PHP, and how do they compare to arrays?

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

How to create random numbers in JS?

How to run an artisan command from a controller

Remove trailing slash (redirect to remove trailing slash) in .htaccess

How to find the index of a value in an array in JS?