note 108775 rejected from function.setlocale by bjori
| From: | bjori@php.net | Date: | Wed, 18 Jul 2012 16:37:27 +0000 |
| Subject: | note 108775 rejected from function.setlocale by bjori | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-189286@lists.php.net to get a copy of this message | ||
Note Submitter: qeremy
----
Be careful when using this "demon" function, or it'll waste your time cos' of a
hidden problem...
What?
If you use this function in a file that included to all project, and if you write functions like
this getUID(), getMyImageSize, getIIIIII etc... then I think you have a problem at this point.
Let me explain;
the_master.php // included to all project and contains this line;
<?php
setlocale(LC_ALL, "tr_TR.UTF-8");
// and after many function defined in these lines, i.e.;
function getUID() {
return (int) $_SESSION["user_id"];
}
?>
...
...
Let's call our function, but...
<?php
$user_id = getUID();
?>
Fatal error: Call to undefined function getUID() in /var/www/...
Yes, we screw up all project. :)
Actually, I don't know what is the exact problem here but I know the solution.
SOLUTION:
1. Do not use "I" (capital "i") character in any function name
or
2. Simply use setlocale like this; setlocale(LC_TIME, "tr_TR.UTF-8") // I need just
locale time config and used this
So, why not use capital i?
I tested a few function name like getUİD(). Yes, it works! (capital i in Türkish İ). But
İ thİnk, many programmer have not thİs char İn theİr keyboards. :)
Additionally, if you use this char in any const name or var name (such as $UID = getuid();) also
your var's and const's will be undefined...