kingandy: (Default)
kingandy ([personal profile] kingandy) wrote2005-09-07 12:50 pm

Random coding fact of the day

One thing I love about php is the ability to go:

$result = mysql_query($query) or die();

The "or" syntax just means, "if this operation returns false, perform this other action" - used mostly for error reporting or whatever.  The "die" function stops processing the page (and, yes, there's usually some useful error message inside those brackets but for the purposes of this post that's not important).

I just really enjoy telling a page to commit seppuku if it fails in its duties.

[identity profile] stsquad.livejournal.com 2005-09-07 02:02 pm (UTC)(link)
A coding idiom inherited from perl. I've probably asked before, but do you grok perl?

[identity profile] stsquad.livejournal.com 2005-09-07 02:34 pm (UTC)(link)
No, its PHP Hypertext Processor

[identity profile] samharber.livejournal.com 2005-09-07 02:38 pm (UTC)(link)
?

PHP stands for PHP Hypertext Processor?

So what does the first PHP stand for?

[identity profile] stsquad.livejournal.com 2005-09-07 03:00 pm (UTC)(link)
Its recursive*.



*see recursive

[identity profile] stsquad.livejournal.com 2005-09-07 04:07 pm (UTC)(link)
Its probably due to recursion being such popular computing algorithm.

[identity profile] renniek.livejournal.com 2005-09-07 02:37 pm (UTC)(link)
PHP always feels to me like a simplified version of Perl, optimised for Web development. The basic syntax is very similar.

[identity profile] stsquad.livejournal.com 2005-09-07 03:00 pm (UTC)(link)
It certainly draws a lot from perl's heratige, including the pcre libraries.

[identity profile] mirabehn.livejournal.com 2005-09-07 06:31 pm (UTC)(link)
I know very little about php (just that [livejournal.com profile] evil_nick is a big fan), but I just wanted to go "yay! yay! yay!" at your choice of music. *grins*

[identity profile] mj-uk.livejournal.com 2005-09-09 04:20 pm (UTC)(link)
didnt perl have a kill function?