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 hide directory listing in .htaccess?

How can you check if a variable is alphanum (alphanumeric, letters and numbers only) in PHP?

What is the max size, by default, of GET variables?

How to redirect your website to a new domain/location in .htaccess

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

A list of operators on Eloquent's where() method

PHP Date commonly used formats

When is __destruct called in PHP?

How to eager load multiple levels of relationships in Eloquent?

How to group a SQL statement in brackets/parenthesis