skip to Main Content

I’m trying to get the php version in the form PHP_MAJOR_VERSION.PHP_MINOR_VERSION :

$ php -r 'print $PHP_MAJOR_VERSION.$PHP_MINOR_VERSION;'
PHP Warning:  Undefined variable $PHP_MAJOR_VERSION in Command line code on line 1
PHP Warning:  Undefined variable $PHP_MINOR_VERSION in Command line code on line 1
$

This doc says :

These constants are defined by the PHP core.

How can I load them ?

2

Answers


  1. $ php -r 'print PHP_MAJOR_VERSION . '.' . PHP_MINOR_VERSION;'
    

    This will do it.

    Login or Signup to reply.
  2. if you want to see in your command line then php –version will show you php version.
    if you want display major and minor separately you should use this example described in —
    https://www.php.net/manual/en/function.phpversion.php

    if you need exact code after trying this. then tell me..

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search