Suppose you have a Windows computer. You can open the console and type some commands there. type dir and get a list of directories and files, copy files with the command copy
: copy c:\a.txt d:\b.txt
this is a windows console. If php is installed on your computer, you can open the console, type something like c:\lamp\php\bin\php -i
and see the php settings.
Now imagine your hosting. An operating system, not Windows, but Linux. Most likely it does not have a graphical shell. Your only way to communicate with him is through the command line.
PHP CLI stands for this: Command Line Interface. Command line interface
If you have ssh access to your site, you can use it to run php scripts in the console, create other console magic.
Log in via ssh to your host (ssh example_user@example.org), get into the console and run php ваш_скрипт.php
The main differences between php-cli and "php via browser":
1) php-cli is executed with the rights of the user who starts it, php-through-browser is executed with the rights of the "user" of the web server.
2) You can run something in the spirit of sudo php someFile.php
and execute it with root privileges (the most important user in the system)
3) In php-cli, by default there is no limit on the execution time of the script.
If you, for example, have forgotten how php works in principle - let me remind you. your server (apache, nginx) receives a request — let's say at index.php — the server sends this request to the php-fpm daemon, which executes the index.php file, and sends the results to the server, and the server to your browser.
It's as if you received a letter from a friend asking you to log in to the console, execute some kind of php script and send the result of the execution back.
Only much faster.
In principle, this is how interpreters of programming languages work, in fact, via the console. Web server support is completely optional.
Details and settings you can find in the manual PHP.