I hate PHP... just hate it. Hate it hate it hate it.
The newest thing I've been dealing with is the idiotic call-time pass-by-reference deprecation. I've never heard the reasoning for the deprecation, and as far as I can tell, there isn't any. I should start keeping a list of all the things that become impossible without it...
- You can't have a default argument in a function that's passed by reference: function ($foo, &$bar = NULL){} doesn't work, although it will in PHP 5. Great, make alternatives available before you deprecate features, assholes.
- Want to append a reference to an array using array_unshift, array_push, etc.? array_unshift($array, &$value) is no good. The only solution for array_unshift is to create new arrays and manually shuffle everything around.
- Want to allow a callback to be called using call_user_func and have its arguments passed by reference? You're out of luck again. The only solution is to wrap a reference to your argument in an array and pass that... and your callback functions have to be rewritten to take arrays.
- Finally, the worst example, which has caused me to waste literally hours trying to fix it is this: I've been removing call-time pass-by-reference from my XML-RPC library, because it's deprecated and people keep getting error messages when using my library (which isn't good). So, I tried to remove call-time pass-by-reference stuff a long time ago when I started working on version 3. So now I started working on the XML parsing part of it, which happens to use xml_set_object. Check out the documentation for that... it uses this line: "xml_set_object($this->parser, &$this);" Which, of course... **IS DEPRECATED**
I'm so mad my head's going to explode... I've been trying very hard to avoid littering this post with four letter words. What this last example shows is that xml_set_object is completely useless without being able to pass an object reference in there, since typically you'll store instance data representing your XML data in that object, and if you don't pass $this by reference you'll wind up with copies all over the place, which is what was happening to me. I think the solution to this is to pass array(&$this, "callback") to xml_set_element_handler, so we'll see.
The last example should work in PHP 5 as well, since objects will be passed by reference and not by value (which was another damn huge design mistake in the first place). But they deprecated a feature, which causes everyone to get big ugly error messages (not even NOTICEs, but WARNINGs) under the default install, without providing any workarounds or replacements.
PHP is a horrid language that I never want to have to do any development with ever again. Unfortunately, there are really no alternatives available that are widely deployed on shared hosts.
|
RSS feed 
Weblog archive
Recent comments
on 14 posts
Blogroll
Countdowns
- 86 days until classes end
- 95 days until finals end
- 237 days until Serenity opens
Must-read sites
Blogroll
powered by blo.gs
Little Green Footballs
42 minutes
Ned Batchelder
1 hour, 43 minutes
Roger L. Simon
2 hours, 30 minutes
The Smallest Minority
2 hours, 51 minutes
Instapundit.com
2 hours, 52 minutes
Country Store
3 hours, 33 minutes
Joseph Scott's Blog
4 hours, 4 minutes
IRAQ THE MODEL
4 hours, 47 minutes
Power Line
4 hours, 54 minutes
A Constrained Vision
5 hours, 11 minutes
TinyApps.Org
5 hours, 27 minutes
manalang.com
8 hours, 14 minutes
Jeremy Zawodny's blog
8 hours, 47 minutes
Legal Theory Blog
10 hours, 23 minutes
Keith's Weblog
18 hours, 45 minutes
alexking.org: Blog
20 hours, 19 minutes
Hack the Planet
21 hours, 8 minutes
Photo Matt
22 hours, 13 minutes
WHEDONesque
23 hours, 14 minutes
Right Wing News
23 hours, 30 minutes
Daily Python-URL! (from the Secret Labs)
1 day, 2 hours
One Hand Clapping
1 day, 3 hours
Lifehacker
1 day, 8 hours
Talideon.com Linklog
1 day, 9 hours
ongoing
1 day, 19 hours
Cox & Forkum
2 days, 3 hours
The Farm: The Tucows Developers' Hangout
2 days, 4 hours
Civilian Gun Self-Defense Blog
2 days, 6 hours
paranoidfish
2 days, 7 hours
why the lucky stiff
2 days, 7 hours
Sam Ruby
2 days, 8 hours
ideoplastos
2 days, 10 hours
Lambda the Ultimate - Programming Languages Weblog
2 days, 11 hours
Loud Thinking
2 days, 16 hours
Amy Ridenour's National Center Blog
3 days
Ping-O-Matic!
3 days, 3 hours
Clayton Cramer's BLOG
3 days, 4 hours
Second p0st
3 days, 7 hours
Simplelinks
3 days, 9 hours
Wunderkinder
3 days, 10 hours
Efectos Especiales
3 days, 23 hours
The Amazin Asian
4 days, 7 hours
Imperialviolet
5 days, 6 hours
American RealPolitik
6 days, 11 hours
vsbabu.org
1 week
Pinging Knight
1 week
Sender Traumwind
1 week, 1 day
Jeff Moore's Blog
1 week, 1 day
Dunstan's blog
1 week, 3 days
Simon Willison's Weblog
1 week, 4 days
blog.se
1 week, 5 days
inluminent
2 weeks
only this, and nothing more
2 weeks, 3 days
Internet Alchemy
2 weeks, 3 days
Keith's Inklings
2 weeks, 5 days
The Fishbowl
2 weeks, 6 days
Kayodeok's Weblog
3 weeks, 4 days
Armed and Dangerous
2 months
Ian Bicking
2 months, 2 weeks
The Daily WTF
2 months, 2 weeks
The PHP WTF
3 months
Squawks of the Parrot
3 months
This page took about 0.231 seconds to generate. |
THANK YOU! I had the weirdest bug in an XML parsing class I wrote recently: for some reason, calls to update and check a property of the class just weren't working. I spent 2 days pulling my hair out about it before cludging it with a global variable (ugh) and moving on. I've just added the & to the $this in my xml_set_element_handler calls and now it works fine.
I am so looking forward to PHP5.