Current Location: Home> Latest Articles> 4 Practical Methods to Check the ThinkPHP Version

4 Practical Methods to Check the ThinkPHP Version

gitbox 2025-06-26

1. Check via Configuration File

In the ThinkPHP framework, you can check the version by looking at the configuration file. In the root directory of the ThinkPHP framework, you will find a file named version.php. By opening this file, you can check its content to determine the current ThinkPHP version being used. Here is an example:


/* Version number */
define('THINK_VERSION', '5.0.24');

From the above code, we can see that the current system is using ThinkPHP version 5.0.24.

2. Check via Command Line

Besides checking the configuration file, you can also check the ThinkPHP version via the command line. In the root directory of the project, open the terminal or command-line window and enter the following command:

<span class="fun">php think version</span>

After executing the above command, the system will output the current ThinkPHP version, such as: ThinkPHP version 5.1.38.

3. Check via Page Code

If you cannot check the ThinkPHP version through the configuration file or the command line, you can also check it through page code. Simply add the following code to any page in the ThinkPHP framework:


/* Output ThinkPHP version */
echo THINK_VERSION;

Then visit the page, and it will output the current ThinkPHP version being used.

4. Check via Built-in Constants

In the ThinkPHP framework, there are built-in constants that can be used to get the ThinkPHP version. Here are two commonly used constants:

4.1. THINK_VERSION

The THINK_VERSION constant is an inbuilt constant in ThinkPHP that directly returns the current ThinkPHP version. You can use the following code on any page to get the ThinkPHP version:


/* Output ThinkPHP version */
echo THINK_VERSION;

Executing this code will display the current ThinkPHP version on the page.

4.2. THINK_VERSION_NUM

The THINK_VERSION_NUM constant is another built-in constant that returns an integer value representing the current ThinkPHP version in numerical form. You can use the following code on any page to get the numerical version:


/* Output ThinkPHP version in numerical form */
echo THINK_VERSION_NUM;

Executing this code will display the current ThinkPHP version in numerical form.

Conclusion

By using the four methods mentioned above, you can easily check the ThinkPHP version in your system. In actual development, knowing the framework version is very important, as it helps you better understand the framework's features and usage, improving your development efficiency.