私はたくさんのものを使用したいが、それらを整理したかったので、外部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文だけを使用していることです。そして、突然、else文があります(この場合、ifも同様です) – Mitch