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 do Invokable Controllers work in Laravel?

How to destroy or remove a cookie in PHP

How to disable file hotlinking in Apache with .htaccess

How to pick what array_intersect function to use in PHP?

How to order a Laravel hasMany relationship?

How to get the type of a variable in JS?

Force trailing slash (redirect if no trailing slash exists) in .htaccess

How to block IPv6 IP addresses in .htaccess

What is camel case?

How to fix the MySQL related "Specified key was too long error" error in Laravel