Are PHP functions case-sensitive, if not…?
I use a lot of these functions in my PHP code; UID()、user_getProfileImage() ... etc
. I write all my projects on Windows and it works fine. No problem here, but when I put my project on my server, it gives an error like this;
fatal error: call /var/www/vhosts/... Undefined function UID().
What the? Is it undefined?!
I’m checking all my project files and again transferring all the files via FTP to the server, again… Same error.
But when I changed the name of UID
() to uid() (
used in lib.php and elsewhere it is located), it worked great.
So what’s the problem? What’s wrong with this server?
Local PHP version: 5.3.10
Server PHP Information: http://… Deleted
Note: I used Notepad++ to encode all PHP files as “UTF-8 without BOM” (as always), and interestingly another project worked just fine, even using the same features and running on the same server.
Thank you.
/##############################/
updates (and solutions);
- Do not use the “I” (uppercase “i”) character in any function name
or - Simply use setlocale like this;
setlocale(LC_TIME, "tr_TR. UTF-8")
I just need locale time configuration and use it If you need
LC_ALL
, don’t forget to set theLC_CTYPE
in theen_US
, i.e.:setlocale(LC_ALL, "tr_TR. UTF-8"); setlocale(LC_CTYPE, "en_US");
Solution
This implies that there is an “I problem” when PHP uses the Turkish locale (tr_TR, tr_TR.utf8
…). When you do this, the check for case-insensitivity between uppercase and lowercase letters “i” fails.
See https://bugs.php.net/18556 — “Set locale to ‘tr_TR’ lowercase class name”
You have several solutions:
- Define and call your function with letters with the same case (or at least the letter “i”); The upper or lower limit does not matter.
- Use a locale that is not affected by this (error) behavior.
The latter is preferred, mainly because it is usually a task that solves all problems with only minor changes.