Case Sensitive?
Archive - Originally posted on "The Horse's Mouth" - 2004-10-19 08:16:20 - Graham EllisPHP variable names are case sensitive, but the names of functions are case insensitive. Why is this?
PHP is a language that's designed to let you write a web page template into which you can insert additional tags to call up the functionality of PHP, and it originated in the days before xhtml when tags were case insensitive. So it's natural for those additional tags to be case insensitive too.
However, following on from other Open Source / Linux / Unix projects, for the most part PHP is case sensitive - a sensible approach as it avoids the loss by folding of 26 ASCII characters in your coding scheme. Also a sensible approach as those of us who use PHP and Perl and Python and other languages appreciate a certain amount of consistency.
It's very easy in PHP to write a piece of code that looks like a "dog's dinner" with a mixture of tags, code, SQL, English all in one file. Following a presentation last week on good PHP practice that I attended, I've written an extra example for our own courses and placed it in our solutions centre - you can see it on this site and learn more about it on our PHP Programming course too.
As an overview ..... split your PHP application into 4 files:
- A Top level that provides the URL for the visitor
- The page template
- Presentation helper logic
- The business logic
You can run the sample in our PHP demo directory