note 108775 added to function.setlocale
| From: | qeremy | Date: | Wed, 23 May 2012 23:20:48 +0000 |
| Subject: | note 108775 added to function.setlocale | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-188182@lists.php.net to get a copy of this message | ||
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...
----
Server IP: 69.147.83.197
Probable Submitter: 78.176.204.54
----
Manual Page -- http://www.php.net/manual/en/function.setlocale.php
Edit -- https://master.php.net/note/edit/108775
Del: integrated -- https://master.php.net/note/delete/108775/integrated
Del: useless -- https://master.php.net/note/delete/108775/useless
Del: bad code -- https://master.php.net/note/delete/108775/bad+code
Del: spam -- https://master.php.net/note/delete/108775/spam
Del: non-english -- https://master.php.net/note/delete/108775/non-english
Del: in docs -- https://master.php.net/note/delete/108775/in+docs
Del: other reasons-- https://master.php.net/note/delete/108775
Reject -- https://master.php.net/note/reject/108775
Search -- https://master.php.net/manage/user-notes.php