Difference between die(_("Access Denied")) and just die("Access Denied")
Permalink
I remember reading something somewhere but I can't find it. At some point the die statement was changed from to
Can someone explain to me the difference? What was that underscore for in the first place, and what bit of code got updated to allow the die statement to work without an underscore?
Perhaps it has something to do with becoming more PSR compliant? According to http://www.php-fig.org/psr/psr-2/:...
Can someone explain to me the difference? What was that underscore for in the first place, and what bit of code got updated to allow the die statement to work without an underscore?
Perhaps it has something to do with becoming more PSR compliant? According to http://www.php-fig.org/psr/psr-2/:...
Property names SHOULD NOT be prefixed with a single underscore to indicate protected or private visibility.
So if its a localization thing, why did the core switch from using an underscore to no underscore? Does that mean "Access Denied" will always be displayed in English?
I can't speak for the core team, but I assume the core team doesn't intend for php's localisation to be used for c5 deployments. As you say, the result is that the message would always be displayed in the language given. The c5 alternative would probably be something like
die(_t("Access denied."));
Yes, but only if php's localisation were being used. If c5's localisation is used, I think it would need to be _t or one of its variants.
But the way the core use to do it is 'die(_("Access Denied' .... What do you think is the reason they switched it to no underscore?
@mnkras explained it here
http://www.concrete5.org/developers/beta/marketplace-community-revi...
At the time any illegal access is made, _ is unlikely to exist, so it wouldn't work anyway. Hence it may as well be die('Access Denied').
However, using _ is not a major issue because anyone getting a code error because _ doesn't exist is likely to be accessing a site illegally anyway. So who cares if they get a code error?
http://www.concrete5.org/developers/beta/marketplace-community-revi...
At the time any illegal access is made, _ is unlikely to exist, so it wouldn't work anyway. Hence it may as well be die('Access Denied').
However, using _ is not a major issue because anyone getting a code error because _ doesn't exist is likely to be accessing a site illegally anyway. So who cares if they get a code error?
http://php.net/manual/en/function.gettext.php...
c5's _t() seems parallel.