Page 1 of 1
Case sensitive
Posted: Sun Sep 23, 2007 2:54 am
by PhpMachine
Hi
Does anyone knows if it's possible to have case sensitive method/function calls?
For instance, if I have a method "Test()", it now approves the call "test()".
But I want it to be case sensitive, if this is possible?
Posted: Sun Sep 23, 2007 4:27 am
by s.dot
I believe this was a limitation of PHP4 and now is case sensitive in PHP5.
Posted: Sun Sep 23, 2007 8:44 am
by feyd
You're generally asking for trouble if you need case sensitive method/function names. I'd suggest reconsidering this.
Posted: Sun Sep 23, 2007 8:51 am
by PhpMachine
Hi scottayy and feyd
I believe this was a limitation of PHP4 and now is case sensitive in PHP5.
Scottayy, do you know if there is a setting for case sensitivness in PHP5?
You're generally asking for trouble if you need case sensitive method/function names. I'd suggest reconsidering this.
Trouble? Why?
Posted: Sun Sep 23, 2007 8:55 am
by feyd
Because you should be using a consistent descriptive naming convention. "Test" is quite vague. Also, if and when other developers need to go into the code, they have to track more information than they really need to in tracing the execution path.
Posted: Tue Sep 25, 2007 9:18 am
by PhpMachine
Hi Feyd
I dont understand you.
I wonder if it is possible to set the PHP "compiler" to raise errors
if my classes/methods etc does not match its declaration?
Like Java and C#, for instance.
Posted: Tue Sep 25, 2007 10:09 am
by feyd
With methods and functions, no. With variables, yes. They will fire general E_NOTICE level warnings. However if you had a consistent naming convention you would reduce the chance of a case problem to almost nothing.
Posted: Tue Sep 25, 2007 11:13 am
by PhpMachine
Of course I have a consistent naming convention.
But sometimes you miss, for instance, a capital letter.
And then it would be very useful to have a compiler that says so

Posted: Tue Sep 25, 2007 11:36 am
by feyd
Unless you modify the underlying code, there is no case sensitivity to methods and function names in PHP. When they are declared they are stored in a hash table. The names stored in the hash table are of a single case. The variable hash is different as it uses different systems of storage.
Posted: Tue Sep 25, 2007 12:05 pm
by PhpMachine
Thank's for your explanations!
