PHP7.1不识别PHP5.6+;语法`使用函数`

PHP7.1不识别PHP5.6+;语法`使用函数`,php,apache,Php,Apache,我有一个在Apache和PHP7.1上运行的PHP网站。 该应用程序在我的PC上运行良好,当我部署到服务器时,出现以下错误: PHP Parse error: syntax error, unexpected 'function' (T_FUNCTION), expecting identifier (T_STRING) or \\\\ (T_NS_SEPARATOR) 当我查看发生错误的位置时,据我所知,这是一个PHP5.6+语法: use function ...; 当我运行php--v

我有一个在Apache和PHP7.1上运行的PHP网站。 该应用程序在我的PC上运行良好,当我部署到服务器时,出现以下错误:

PHP Parse error: syntax error, unexpected 'function' (T_FUNCTION), expecting identifier (T_STRING) or \\\\ (T_NS_SEPARATOR)
当我查看发生错误的位置时,据我所知,这是一个PHP5.6+语法:

use function ...;
当我运行
php--version
哪个php
时,它显示它是PHP7.1。 是否有一个设置将php配置为允许语法高于特定版本

编辑: phpinfo()正在报告PHP5.5.9
我想我需要的是关于如何将Apache设置为在我的服务器上使用默认PHP版本7.1的帮助。

答案是禁用模块PHP5并为Apache启用7.1:

use keywork will support all version of php. i think your function declaration error. 
you can use below example and correct your function
**use** can only be used with anonymous functions. Using it with named functions 
 gives a syntax error.

 <?
function counter($start) {
  $value = $start;

 return function() use (&$value) {
   return $value++;
 };
sudo a2dismod php5
sudo a2enmod php7.1
sudo service apache2 restart

您确定Apache使用save php版本作为web服务器的cli吗?Put
phpinfo();退出输入到代码中,并向我们显示结果。@lawrencerone
use function
在PHP中是有效的。phpinfo正在报告PHP版本5.5.9,我想我需要将apache设置为使用默认的PHP,在本例中为7.1。我将编辑question@LawrenceCherone如果我们不知道导入的函数,那么您肯定是如何说它因为
函数
而抱怨的?@lawrencerone,正如我之前所说的,同样的代码在我的电脑上运行,因为我的电脑正确运行了PHP7.1。因此,问题都与PHP版本有关,而不是与代码有关。
sudo a2dismod php5
sudo a2enmod php7.1
sudo service apache2 restart