lundi 19 décembre 2016

PHP - If statement errors with includes

I am trying to include parts of an if statement from external php files because i wanted to use lots of them but have them organized.

I get the error - Parse error: syntax error, unexpected 'else' (T_ELSE)

My main code is:

<?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;

?>

And the General.php etc included are like this:

<?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');
}

?>

Aucun commentaire:

Enregistrer un commentaire