Case sensitive

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
PhpMachine
Forum Commoner
Posts: 42
Joined: Thu Apr 19, 2007 11:26 am

Case sensitive

Post 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?
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Post by s.dot »

I believe this was a limitation of PHP4 and now is case sensitive in PHP5.
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

You're generally asking for trouble if you need case sensitive method/function names. I'd suggest reconsidering this.
PhpMachine
Forum Commoner
Posts: 42
Joined: Thu Apr 19, 2007 11:26 am

Post 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?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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.
PhpMachine
Forum Commoner
Posts: 42
Joined: Thu Apr 19, 2007 11:26 am

Post 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.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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.
PhpMachine
Forum Commoner
Posts: 42
Joined: Thu Apr 19, 2007 11:26 am

Post 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 :)
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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.
PhpMachine
Forum Commoner
Posts: 42
Joined: Thu Apr 19, 2007 11:26 am

Post by PhpMachine »

Thank's for your explanations! :)
Post Reply