There is an inconsistency issue between opening phpinfo in the browser and executing phpinfo on the command line.
过去多啦不再A梦
过去多啦不再A梦 2017-06-26 10:48:55
0
2
1281
  1. Operating system: MAC OS

  2. The script v.php opened by the browser

    <?php
    phpinfo();
    输出的版本是``PHP Version 5.6.30``
  3. The command line executes php v.php, the output version is:

    PHP 7.1.6 (cli) (built: Jun 26 2017 00:06:58) ( NTS )
    Copyright (c) 1997-2017 The PHP Group
    Zend Engine v3.1.0, Copyright (c) 1998-2017 Zend Technologies

Is this what is the reason?

过去多啦不再A梦
过去多啦不再A梦

reply all(2)
为情所困

Maybe there are two versions of PHP on the computer.
The PHP version used by the localhost server mounted by Apache is 5.6;
The PHP version used by the global php command is 7.1.

漂亮男人

Amend this sentence in /etc/apache2/httpd.conf


#LoadModule php5_module /usr/local/Cellar/php56/5.6.15/libexec/apache2/libphp5.so
LoadModule php7_module        libexec/apache2/libphp7.so  //具体地址也可能不是这个,自己搜下 

There is also a function to load configuration

cd /etc/apache2/other/
sudo cp php5.conf php7.conf  
chmod 755 php7.conf #原文件只可读不可写

Modify php7.conf

<IfModule php7_module>
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps

<IfModule dir_module>
        DirectoryIndex index.html index.php
</IfModule>
</IfModule>

Modify httpd.conf

#Include /private/etc/apache2/other/*.conf  #注释

 添加

 <IfModule php5_module>
        Include /private/etc/apache2/other/php5.conf
 </IfModule>
    <IfModule php7_module>
        Include /private/etc/apache2/other/php7.conf
    </IfModule>
    
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template