我想包括外部php文件的if语句的部分,因为我想使用它们中的很多,但有他们组织。PHP - 如果语句错误包括
我得到的错误 -
Parse error: syntax error, unexpected 'else' (T_ELSE)
我的主要代码:
<?php
require 'Lib/Functions.php';
$message = "hello";
if($message == '') {
$message_to_reply = Pick('|Please ask me a question|Got any questions?|Want to talk?');
}
include 'Response/Data.php';
include 'Response/General.php';
else {
$message_to_reply = 'Sorry, im not sure what you mean?';
}
echo $message_to_reply;
?>
而且包括General.php等都是这样的:
<?php
elseif(preg_match('[hello|hi|Greetings]', strtolower($message))) {
$message_to_reply = Pick('Hi there!|Hello there!|Hi, it\'s nice to meet you|Greetings');
}
?>
您正在编写if语句。然后包含2个项目(不在if或else中),然后出现else声明。所以问题是,你只使用if语句。然后突然有一个其他的声明(在这种情况下,应该是一个如果也是) – Mitch