PHP case sensitivity @#&^%!

The other day I finally figured out why some people are so violently opposed to PHP. When using object oriented features of PHP5 I discovered the hard way that PHP has some weird, backwards compatibility issue rules how it handles case.

In a nutshell, variables are case sensitive, but function names, and object methods (!!!) are not.

That explains why the following code does not work

<?php
class A {
function
GET($url) {
 
// retrieve the url
}
}
class
B extends A {
private var
$foo;

function
get($var) {
  return
$this->foo;
}
}
?>

I know, this case could be handled with __get or __call, but still, it doesn't hurt to know that $this->get and $this->GET are one and the same, as far as PHP5 is concerned.

http://bugs.php.net/bug.php?id=26575

Your rating: None Average: 1.5 (2 votes)

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
I was confused as well by amosbatto (not verified)