Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/joomla/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
&引用&书信电报;br/>&书信电报;b>;解析错误</b>;:语法错误,意外';{&&x27;在<;b>;/home/site/public\u html/devel/modules//filter.php<;/b>;在线<;b>;35<;/b>;<;br/>;_Php_Joomla_Joomla Module - Fatal编程技术网

&引用&书信电报;br/>&书信电报;b>;解析错误</b>;:语法错误,意外';{&&x27;在<;b>;/home/site/public\u html/devel/modules//filter.php<;/b>;在线<;b>;35<;/b>;<;br/>;

&引用&书信电报;br/>&书信电报;b>;解析错误</b>;:语法错误,意外';{&&x27;在<;b>;/home/site/public\u html/devel/modules//filter.php<;/b>;在线<;b>;35<;/b>;<;br/>;,php,joomla,joomla-module,Php,Joomla,Joomla Module,我面临着一个非常奇怪的问题,一个脚本在两周前运行,现在抛出以下错误: "<br /> <b>Parse error</b>: syntax error, unexpected '{' in <b>/home/site/public_html/devel/modules/filter.php</b> on line <b>35</b><br /> " “分析错误:语法错误,第35行的/home/sit

我面临着一个非常奇怪的问题,一个脚本在两周前运行,现在抛出以下错误:

"<br /> <b>Parse error</b>: syntax error, unexpected '{' in <b>/home/site/public_html/devel/modules/filter.php</b> on line <b>35</b><br /> "

分析错误:语法错误,第35行的/home/site/public_html/devel/modules/filter.php中出现意外的“{”
这是代码,我已经看了上千遍了,但我不知道里面出了什么问题

   <?php

define('_JEXEC',1); 
define('JPATH_BASE', realpath(dirname(__FILE__).'/../..' ));

require_once(JPATH_BASE.'/includes/defines.php');
require_once(JPATH_BASE.'/includes/framework.php');
$mainframe = JFactory::getApplication('site');
$mainframe->initialise();
$db = JFactory::getDBO();

ob_start();
header("Access-Control-Allow-Origin: *");
header('Content-Type: application/json');


  function getCountries() {
     try {
       $db = JFactory::getDBO();
       $query = "SELECT id, name FROM `#__countries`";
       $db->setQuery($query);
       $result =  $db->loadRowList();
       if(!$result) {
         throw new exception("Country not found.");
       }
       $res = array();
          foreach($result as $key=>$value) {
        $res[$value[0]] = $value[1];
       }
       $data = array('status'=>'success', 'tp'=>1, 'msg'=>"Countries fetched successfully.", 'result'=>$res);
     }
     catch (Exception $e) {
       $data = array('status'=>'error', 'tp'=>0, 'msg'=>$e->getMessage());
     } 
     finally {
        return $data;
     }
   }

  // Fetch all states list by country id
  function getStates($countryId) {
     try {
       $db = JFactory::getDBO();
       $query = "SELECT id, name FROM #__states WHERE country_id=".$countryId;
       $db->setQuery($query);
       $result =  $db->loadRowList();
       if(!$result) {
         throw new exception("State not found.");
       }
       $res = array();
         foreach($result as $key=>$value) {
        $res[$value[0]] = $value[1];
       }
       $data = array('status'=>'success', 'tp'=>1, 'msg'=>"States fetched successfully.", 'result'=>$res);
     } catch (Exception $e) {
       $data = array('status'=>'error', 'tp'=>0, 'msg'=>$e->getMessage());
     } finally {
        return $data;
     }
   }

 // Fetch all cities list by state id
  function getCities($stateId) {
     try {
       $db = JFactory::getDBO();
       $query = "SELECT id, name FROM #__cities WHERE state_id=".$stateId;
       $db->setQuery($query);
       $result =  $db->loadRowList();
       if(!$result) {
         throw new exception("City not found.");
       }
       $res = array();
         foreach($result as $key=>$value) {
        $res[$value[0]] = $value[1];
       }
       $data = array('status'=>'success', 'tp'=>1, 'msg'=>"Cities fetched successfully.", 'result'=>$res);
     } catch (Exception $e) {
       $data = array('status'=>'error', 'tp'=>0, 'msg'=>$e->getMessage());
     } finally {return $data;}}   

try {
  if(!isset($_GET['type']) || empty($_GET['type'])) {
    throw new exception("Type is not set.");
  }
  $type = $_GET['type'];
  if($type=='getCountries') {
    $data = getCountries();
  } 

  if($type=='getStates') {
     if(!isset($_GET['countryId']) || empty($_GET['countryId'])) {
        throw new exception("Country Id is not set.");
     }
     $countryId = $_GET['countryId'];
     $data = getStates($countryId);
  }

   if($type=='getCities') {
     if(!isset($_GET['stateId']) || empty($_GET['stateId'])) {
        throw new exception("State Id is not set.");
     }
     $stateId = $_GET['stateId'];
     $data = getCities($stateId);
  }

} catch (Exception $e) {
   $data = array('status'=>'error', 'tp'=>0, 'msg'=>$e->getMessage());
} finally {
  echo json_encode($data);
}

ob_flush();
?>


有人能告诉我出了什么问题吗?

在PHP 5.6上解析得很好。第35行是
finally
关键字。如果你的PHP版本早于5.5,我想你会在这里遇到解析错误。

什么版本的PHP?
finally
需要PHP>=5.5HP当前安装的版本是5.4.5。谢谢,我没有意识到这可能会发生可能是由PHP版本引起的