Problem of different PHP versions reported

前端 未结 2 1562
心在旅途
心在旅途 2021-01-18 19:15

I have upgraded to PHP 5.3 on a development machine (Windows 7 box).

php-v shows

PHP 5.3.3 (cli) (built: Jul 21 2010 20:36:55)
Copyright (c) 1997-20         


        
相关标签:
2条回答
  • 2021-01-18 19:34

    Your command line (CLI) php is an other version than the one used for Apache. Check also that both use the same php.ini. When you call on your Windows machine

    c:\path\to\php\php.exe -v 
    

    or

    c:\path\to\php\php-win.exe -v 
    

    and

    c:\path\to\php\php-cli.exe -v 
    

    They all can return different versions. Often this happens when upgrading to a new WAMP version and forgetting to delete the old versions. I'm sure you will find the executable PHP binary which matches the same version. It is also save to use the php.exe or php-win.exe instead the php-cli.exe on Windows.

    0 讨论(0)
  • 2021-01-18 19:47

    Hello

    You should also update apache php module


    @soju - that fixed it, thanks, but I thought I'd make this a little clearer for others.

    Apache requires the php module to serve php files. On Windows it comes as a .dll file. This would be called: php5apache2_2.dll - located within your php folder. Strangely though, during upgrading the php folder with a newer version, you may find out that apache still uses the old php module file. So while php -v correctly reports the new version, Apache still looks at the old php module (reported by phpinfo). To find out what module version you have, you could: right-click on the .dll file > select properties -> view the details tab. Or just hover on the file.

    details screen of php5apache.dll file

    If this version is not what you want, you might want to hunt for a newer version and replace it. Good idea to back up first. Also, the php5apache.dll file works with and requires the file: php5ts.dll - so ensure these files are the same versions.

    With your httpd.conf file with the directive:

    LoadModule php5_module "\path to\php5apache2_2.dll"
    

    You may restart apache and smile!

    0 讨论(0)
提交回复
热议问题