I was thinking which way is the best to store constants inside config files, especially for translations.
Smarty has this done nicely with a Config class:
Code: Select all
# global
siteName = "mod-forge.org"
pageTitle = "mod-forge.org"
[Maintainance]
msg = "The site is currently under maintainance, please try later."
[Register]
pageTitle = "User registration"
label_username = "Username"
label_password_1 = "Password"But how do you read and "register" all these without much struggle in php? If I load the file into an array then there are lots of operations to check, explode, assign...
How about this:
Code: Select all
<?php
// error codes
define('INPUT_ERROR_VALUE_MISSING', 'This field is required');
define('INPUT_ERROR_VALUE_SHORT', 'Value is too short');
define('INPUT_ERROR_VALUE_LONG', 'Value is too long');
define('INPUT_ERROR_VALUE_WRONG', 'This value is invalid');
define('INPUT_ERROR_INVALID_EMAIL','This is not a valid e-mail adress');
define('INPUT_ERROR_INVALID_URL','This is not a valid URL');
define('INPUT_ERROR_CHECKS_FEW','Not enough options checked');
define('INPUT_ERROR_CHECKS_MANY','Too many options checked');What do you use? How about XML files?
Btw I dropped smarty, won't be having it in my "back-end", that's why I am looking what to do with the configs...