[Latest version of Reiwa] About the influence of PHP version and how to check it
table of contents
Introduction
Hello, I'm [Enoki] from the System Development Department, and this time I'm going to write an article about checking the PHP version.
By the way, if the PHP version is old, there will be problems and impacts on security etc.
(Actually) I won't specifically touch on that in this article, so
if you 're not familiar with how web systems work, but you're curious about the effects of PHP version differences, I recommend the article below
[Explanation] Effects and countermeasures caused by differences in PHP versions
For now, this is "this".
php -v
It's OK if the version information appears like this.
PHP 8.2.1 (cli) (built: Jan 11 2023 07:28:38) (NTS) Copyright (c) The PHP Group Zend Engine v4.2.1, Copyright (c) Zend Technologies with Xdebug v3.2.2, Copyright (c ) 2002-2023, by Derick Rethans
You can almost hear someone saying, "I know this many commands, but I can't find the version, so I'm looking into it!"
If that is the case (version information does not appear), the execution location may be incorrect.
'php' is not recognized as an internal or external command, operable program or batch file.
About execution location
Here are the execution locations in typical environments and what to do if it still does not appear.
Environment Linux/Windows
First is the environment.
Linux: Start a terminal and run
php -v
Windows: Start a command prompt (or PowerShell) and run php -v
Execution location (for those wondering what an arbitrary directory is)
The arbitrary directory is the directory where PHP is installed.
If you think about it, it's obvious, but you can't run it in a place where PHP doesn't exist.
You can find the PHP installation location by running the command below.
Linux:
# Command to find PHP installation location find / -type f -name "php" -executable -print
Windows:
# Command in terminal to find PHP installation location dir /s /b php.exe
# Command in PowerShell to find the PHP installation location where.exe php
Running these commands will display the path where PHP is installed.
Once you know the location of PHP
you run the above command and see a path like /usr/local/bin/php
the /php
at the end to move to the execution location as follows.
# Example command to move to PHP installation location cd /usr/local/bin
After that, php -v
should display PHP version information correctly.
Now you can now execute PHP commands, but
to be honest, it's a pain to have to go all the way here every time.
So let's continue for a little while.
Executable from anywhere via path
Once you find the PHP location (installation directory) you can pass it through.
This allows you to use PHP executables in any directory.
Linux
Add the path by running the following command in Terminal:
export PATH=$PATH:[installation path]
For example, if the PHP installation path is /usr/local/bin
, it will look like this:
This installation path is the path to the php installed directory (location) that you discovered earlier.
export PATH=$PATH:/usr/local/bin
For Windows
In Windows, you can pass the path by changing the environment variable settings.
1. Search for and open “Edit System Environment Variables”.
2.Click the "Environment Variables" button.
3. Select the Path environment variable in the System Environment Variables section and click Edit.
4.Click the New button to add the PHP installation path.
5. Save your changes and close the dialog.
This will add the PHP installation path to the environment variable Path and make it passable.
Now you can execute PHP commands without having to move each time! !
Please use it for a comfortable PHP life! !