Page 1 of 4
Things in php that made you go WHOA!
Posted: Tue Jun 06, 2006 12:55 am
by Luke
I am just discovering things in php that I never even knew about... like output buffering... things that should have been explained somewhere along the line in my 3 or 4 years of off and on php-learning. In this thread, I would like for everybody to just sort of point out a few things that are very useful, but often are over-looked by new-comers or lazy php programmers like myself. Then I would like for you to explain their usage, and maybe even give some examples. Begin!

Posted: Tue Jun 06, 2006 2:45 am
by bmcewan
Found an interesting article on output buffering that others may find useful.
http://www.zend.com/zend/art/buffering.php
I too have been missing out on this functionality, not so much laziness as blind ignorance.
Posted: Tue Jun 06, 2006 3:51 am
by shiznatix
Although it's not that amazing...
cURL() is awesome in my opinion. I had never heard of such a thing before that (ya I was a n00b but still!) and it just blew my mind that you could be a user without being there. That made me go wow.
Posted: Tue Jun 06, 2006 4:35 am
by Maugrim_The_Reaper
The taken-for-granted PHP sessions made my day a long time back when starting. Ah, the good old days...
Currently, I think cURL is the coolest of them all. I haven't used it a lot so I'll be taking a time out at some stage to learn more about it in detail...
Posted: Tue Jun 06, 2006 7:17 am
by sweatje
Probably regular expressions fit somewhere in that list, though in PHP they feel a bit like second class citizens when compared with Perl or Ruby.
Posted: Tue Jun 06, 2006 10:00 am
by Luke
These are all great... how about some concepts? Anybody have any php design techniques they found particularly interesting?
Posted: Tue Jun 06, 2006 10:17 am
by sweatje
One technique I use sometimes is to create a Monostate object by binding a varaible to a key in one of the PHP SuperGlobals. For example, if I want a queue of notifications, I might bind an attribute to a key in the $_SESSION array and then any instance of that class can add to, or display and clear, the queue.
Here was something I wrote up on that technique:
http://blog.casey-sweat.us/?p=18
Posted: Tue Jun 06, 2006 10:22 am
by Charles256
I just learned that
is a perfectly valid short cut to
I had no idea.
Posted: Tue Jun 06, 2006 10:56 am
by John Cartwright
Charles256 wrote:I just learned that
is a perfectly valid short cut to
I had no idea.
What happens when short tags arn't enabled? I've heard several horror stories when porting large projects to a new host to find out their code no longer works.
Posted: Tue Jun 06, 2006 11:01 am
by Maugrim_The_Reaper
Can I shoot him? Please?
You should try stick with the longer tag form - it's more portable. The use of short_tags option in PHP is optional, so it's not supported on all hosts.
Posted: Tue Jun 06, 2006 11:06 am
by Luke
There's no need for violence... let's just stay on topic

Posted: Tue Jun 06, 2006 11:28 am
by Charles256
for the record, it wasn't my code. i always use the long form. it was in code i was working on. so bite me

. now, back on topic.
Posted: Tue Jun 06, 2006 11:33 am
by John Cartwright
Object Oriented Programming and design patterns..

Posted: Tue Jun 06, 2006 11:40 am
by RobertGonzalez
This may sound really newbie-ish, but my favorite feature of PHP has been the array functions. When I learned what an array was and how to use them properly, my code development eyes were opened.
Now it is more the object oriented approach that can be taken when developing (that whole passing by reference thing is pretty cool too). But really, everyday there is something that I run across that makes me say "Dude, this is the coolest language!".
Posted: Tue Jun 06, 2006 11:50 am
by Todd_Z
This isn't really php, but linux has brought many moments like that. Especially when you know a scripting language, which isn't really the best CLI language, but still, if I need a linux applet, I can just whip something up in php, 10 minutes later, I have a script that does whatever I want - from rotating background images, to talking to microcontrollers. The whole thing is amazing to me.