'; ?> DomCore Demos, a WebAbility® Network Project
« Back to the index

\core\WAMessage example

Let's build a basic error messaging system in in spanish.
Then let's call a database connector, and throw an error in spanish if there is an error (simulated):

'Error, the database could not be loaded', 'config' => 'Error, the configuration file could not be loaded' ); \core\WAMessage::addMessages($mymessages); // We set core default spanish messages (optional) \core\WAMessage::setMessagesFile('../messages/messages.es.xml'); // we set our spanish messages ('database' and 'config' entries) \core\WAMessage::setMessagesFile('./message.es.xml'); // loading the framework // ... // We load the framework configuration $configfile = './config.php'; if (!file_exists($configfile)) { print \core\WAMessage::getMessage('config'); } else { // load the config file // We connect to the DB if (!mysqli_connect('localhost', $config['username'], $config['password'])) { throw new \core\WAError(\core\WAMessage::getMessage('database')); } else { // call the framework // ... } } ?>

« Back to the index