[Reiwa Latest Edition] Impact of PHP Versions and How to Check Them

table of contents
Introduction
Hello, this is Enoki from the System Development Department. This time, I'll be writing an article about checking your PHP version
By the way, if the PHP version is old, it may cause problems or impact security
(Actually) this article doesn't really go into that, so if you're someone who
's not familiar with web-related systems but is curious about the impact of PHP version differences,
articlebelowis a better choice.
[Explanation] Impact of different PHP versions and countermeasures
For now, this is it
php -v
If the version information appears like this, then it's OK
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
"Of course I know these commands, but I'm looking it up because the version isn't showing up!!"
You can almost hear someone saying,
If this happens (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
Where to run
This is about where to run a typical environment and what to do if it still doesn't appear
Environment Linux/Windows
First of all, the environment
Linux: Open a terminal and `php -v`run
Windows: Open a command prompt (or PowerShell) and `php -v`run
Execution location (for those wondering what an arbitrary directory is)
By any directory, I mean the directory where PHP is installed
If you think about it, it makes sense, but it cannot be executed in a place where PHP does not exist
You can find the location of your PHP installation by running the following command:
Linux:
# Command to find the PHP installation location find / -type f -name "php" -executable -print
Windows:
# Command in terminal to find PHP installation location dir /s /b php.exe
# PowerShell command to find the PHP installation location: where.exe php
This command will print the path to your PHP installation location
Once you know the location of PHP
you execute the above command and /usr/local/bin/php is displayed,
the trailing /php and navigate to the execution location as follows:
# Example of command to move to PHP installation location cd /usr/local/bin
After that,`php -v` should display the correct PHP version information.
So, technically, you can now execute PHP commands, but
honestly, it's a hassle to navigate back here every time.
Therefore, we'll continue for a little longer.
Can be executed from anywhere through a path
Once you've located PHP (its installation directory), you can add it to your system
's PATH. This allows you to use the PHP executable from 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 would look like this.
This installation path is the path to the directory (location) where PHP was installed, which we discovered earlier.
export PATH=$PATH:/usr/local/bin
For Windows
On Windows, you can change the environment variable settings to allow the path
1. Search for and open "Edit system environment variables".
2. Click the "Environment Variables" button.
3. In the "System environment variables" section, select the "Path" environment variable and click "Edit".
4. Click the "New" button and add the PHP installation path.
5. Save the changes and close the dialog.
This will add the PHP installation path to the Path environment variable, making the path valid
Now you can execute PHP commands without having to switch locations every time!
Enjoy a more convenient PHP experience!
10
