Things in php that made you go WHOA!

Ye' old general discussion board. Basically, for everything that isn't covered elsewhere. Come here to shoot the breeze, shoot your mouth off, or whatever suits your fancy.
This forum is not for asking programming related questions.

Moderator: General Moderators

User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Post by s.dot »

hmm made me go wow.

Just PHP in general :lol: As my first programming language I still get excited every now and then at the things it's capable of. This board makes me go wow. So many members with so many great projects and so much knowledge. Errm, the implementation of classes make me go wow. Learning standards make me go wow.... i can add more later.. after I think for a bit.

[edit]echo str_replace('wow','whoa',$myPost); ;)
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
alex.barylski
DevNet Evangelist
Posts: 6267
Joined: Tue Dec 21, 2004 5:00 pm
Location: Winnipeg

Post by alex.barylski »

always use HEREDOC syntax, especially for SQL statements. Look at the difference
Nice...never even thought of using it for SQL...

That is actually nice :)
User avatar
daedalus__
DevNet Resident
Posts: 1925
Joined: Thu Feb 09, 2006 4:52 pm

Post by daedalus__ »

Everything about PHP makes me go wow. I came from ASP :- /
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

I feel you. The first 'programming' I ever did outside of HTML was PHP. When my department needed some development done I said I'd do it not knowing that the preferred platform is all Windows. Talk about a culture shock. ASP sucked (C#.NET is pretty neat, but that is for another discussion). Anyway, I learned what I needed to, but it hurt my stomach :cry: .
User avatar
patrikG
DevNet Master
Posts: 4235
Joined: Thu Aug 15, 2002 5:53 am
Location: Sussex, UK

Post by patrikG »

sweatje wrote: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
Interesting idea. Conceptually makes sense for a multi-user app, but that's true for any global. As a matter of fact, it is, as you say, a global by sneak. And given that singletons have recently gotten such a bad name... oooh ;) I've never really understood the reason why they were suddenly bad, seems more like a fashion. One day they're in, the next they're out.

"Breaks the unit tests" I read somewhere. No idea, to be honest, but if that's so, write a better unit test program, guys.
I like your idea, but you can really only get away with that if you know what you're doing - and most people don't ;)
User avatar
sweatje
Forum Contributor
Posts: 277
Joined: Wed Jun 29, 2005 10:04 pm
Location: Iowa, USA

Post by sweatje »

patrikG wrote: "Breaks the unit tests" I read somewhere. No idea, to be honest, but if that's so, write a better unit test program, guys.
It does not "break the tests", it hard codes a dependency into your code, which in turn increases the coupling and make the testing harder. It not the testing which is broken, it is the design of the code being tested. Designing code using a test first habit leads to "highly cohesive, loosely coupled" designs. The Singleton is thus an impediment to this goal, hence it's evil reputation.

HTH
User avatar
seodevhead
Forum Regular
Posts: 705
Joined: Sat Oct 08, 2005 8:18 pm
Location: Windermere, FL

Post by seodevhead »

Thank god MySQL got a FULLTEXT index. Could you imagine if we still had to use %LIKE%??? ;-)
Charles256
DevNet Resident
Posts: 1375
Joined: Fri Sep 16, 2005 9:06 pm

Post by Charles256 »

fulltext index? i still use like...um.... : hides : enlightenment?
User avatar
seodevhead
Forum Regular
Posts: 705
Joined: Sat Oct 08, 2005 8:18 pm
Location: Windermere, FL

Post by seodevhead »

Charles256 wrote:fulltext index? i still use like...um.... : hides : enlightenment?
?????? :?:
User avatar
daedalus__
DevNet Resident
Posts: 1925
Joined: Thu Feb 09, 2006 4:52 pm

Post by daedalus__ »

What's a HEREDOC syntax?

A standard?
User avatar
PrObLeM
Forum Contributor
Posts: 418
Joined: Sun Mar 07, 2004 2:30 pm
Location: Mesa, AZ
Contact:

Post by PrObLeM »

get_meta_tags http://www.php.net/get_meta_tags it saved me from paring html in php4
User avatar
sweatje
Forum Contributor
Posts: 277
Joined: Wed Jun 29, 2005 10:04 pm
Location: Iowa, USA

Post by sweatje »

Daedalus- wrote:What's a HEREDOC syntax?

A standard?

Code: Select all

$str = <<<GO_TIL_YOU_SEE_ONE_OF_THESE
This is a HEREDOC string.

It can be multiline,
contain both " and ' quotes
and supports $variable substitution
GO_TIL_YOU_SEE_ONE_OF_THESE;
http://www.php.net/manual/en/language.t ... ax.heredoc
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Post by Benjamin »

Jcart wrote:
Charles256 wrote:I just learned that

Code: Select all

<?=$var?>
is a perfectly valid short cut to

Code: Select all

<?php echo $var; ?>
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.
Find and Replace <? to <?php ? I wouldn't think it would be a show stopper.
User avatar
Maugrim_The_Reaper
DevNet Master
Posts: 2704
Joined: Tue Nov 02, 2004 5:43 am
Location: Ireland

Post by Maugrim_The_Reaper »

I don't think you can use

Code: Select all

<?php=
though. So using the short tag

Code: Select all

<?=
needs a little more work to replace.
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

Seriously though, even though you can use it doesn't mean you should. Beside, what is so hard about writing...

Code: Select all

<?php
$mydate = ( date("Y") == 2006 ) ? 'It is 2006' : 'It is a different year';
?>

<p>What year is it: <?php echo $mydate; ?></p>
Post Reply