php -v vs phpinfo() shows different result

  • | 54 points

    php -v
    PHP 7.4.7 (cli) (built: Jun 9 2020 13:36:15) ( ZTS Visual C++ 2017 x64 )
    Copyright (c) The PHP Group
    Zend Engine v3.4.0, Copyright (c) Zend Technologies

    PHP Version 7.2.19

    why are they different

  • administrators
    | 131219 points

    @Ojha007 : Did you install PHP elsewhere?

  • | 14 points

    Console use CLI version and your website use FPM versión

  • | 9869 points

    There are several reasons why you see a difference. My first guess would be you updated PHP 7.4.7, but didn't update the path. Open Laragon, Menu > Tools > Path > Manage path. You will see a screen showing ---Laragon --- with all the installed software then --- user --- with the user path, then ---- system ---- with the system path. My guess is the user section is empty and you are using a different command line (CMD or shell), look at the system section to see if there is a line for the previously installed CLI version. possibly in c:\php.

    • IF there is one in there, google how to add a program to system path, but remove that line instead.
    • IF the user section is filled. Check the line, it would be c:\laragon\php\php-7.2.19-Win32-VC15-x64 (I think this is the default laragon ships with). To remove it goto the top right corner and (green Menu)> remove laragon from path. Log off and back on Windows. Then open Laragon select PHP 7.4.7. (Laragon > Menu > PHP > Version [PHP ...currently selected...] > click the one you want to use. Then add to path (Menu > Tools > Path > Manage path), check the user path is empty (of the laragon program) menu > Add to Path, log off and back on. Your CLI version and phpinfo version will be in sync, regardless of the command tool used.

    Let us know how you get on.

Log in to reply

Looks like your connection to Laragon was lost, please wait while we try to reconnect.