Why don't you have the choice to not use PHP?
Because that's one of the project requirements, and the server that the project is going on only supports PHP.
Believe me, I'd love to be able to use ASP.NET.
Maybe it took offense to the filename?
Nah, I redacted that and the path name. If anything it probably took offense to the names that I was calling it.
http://en.wikipedia.org/wiki/Scope_resolution_operator
lawl
Seriously, that is fucking ridiculous.
Yeah, that was one of the results that I ran into when I was trying to figure out what the hell that message meant. It kind of proves the point that the language was never actually designed.
See, I can very well understand having scope operators. It's essential when you're working with namespaces, for one. I can understand actually having scope as well, for obvious reasons.
The problem is that PHP decided to replace the tried-and-true "inherit-from-parent-function" concept with its own logically flawed model. For instance, the following PHP "code":
$b = "sucks.";
function fuckMeSilly($a) {
echo "$a $b";
}
function rogerMeSenseless() {
fuckMeSilly("PHP");
}
rogerMeSenseless();
Will produce the output: "
PHP ". Forget the fact that $b is clearly a global variable, not to mention that it's in a block that's a parent of the said function.
The "proper" way to write the code is as follows:
$b = "sucks.";
function fuckMeSilly($a) {
global $b;
echo "$a $b";
}
function rogerMeSenseless() {
fuckMeSilly("PHP");
}
rogerMeSenseless();
To make matters worse, the project that I'm working on is partially implemented as a Joomla module. This is where PHP's function "design" really falls apart. The second code example that I posted still does not work in this environment, because I'm technically already working as a function of the Joomla code (and yes, PHP does, in fact, support sub-functions...it's just bizarre). The "proper" way to implement this function is to add another global tag to the top, as follows:
global $b;
$b = "sucks.";
function fuckMeSilly($a) {
global $b;
echo "$a $b";
}
function rogerMeSenseless() {
fuckMeSilly("PHP");
}
rogerMeSenseless();
And, finally, our Joomla (or Jumi, since I've been using that for some things as well) module will finally print the intended and exceedingly true message: "
PHP sucks."
Wow. Really, the code above makes absolutely no sense. And yes, that is exactly what you have to do: declare the variable as global, then declare that it's a global
again inside of the parent function. It just blows my mind how incompetent this behavior is. It is so incredibly awkward to use that I don't understand who thought that it was a good idea to make it like that.
To make matters worse, this is apparently how PHP classes have to access the class variables. And here I was thinking that the reason for classes was to create a big, unified object with the ability to have limited exposure to the outside code. I've never seen another language that requires so much voodoo magic just to access class variables.
Ugh. It's just painful to think about. I fucking hate it.