Re: New years resolution: To get serious with my programming! Anyone wanna help? :)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Jan 15, 2008 6:42 PM, Jochem Maas <jochem@xxxxxxxxxxxxx> wrote:
> funny that, I usually use 'exit;' for a clean exit and 'die();' to signify
> a shitty exit ... although they are actually indentical functionally - just
> my idiosyncrasity ... that said I also so stuff like 'exit(1);' when I really
> want to offer a proper exit code. :-/
[snip!]

    While I'd be more inclined to believe that die() would be
considered more of a function (which is why I continue to write it
with the attached parentheses) than a language construct (such as
'exit'), it appears to be nothing more than a matter of semantics in
PHP.  Whereas Perl, where I was prior to PHP[^1] had noticeable and
usable differences between exit and die().

    See here:
        http://perldoc.perl.org/functions/exit.html

    You can successfully use die without parentheses, which may lead
some to believe that it is DEFINITELY not a function.... but to combat
that, you can use any function that doesn't require parameters (i.e.
time(), ob_start(), ob_end_clean(), etc.) without parentheses as well,
and there will be no errors.

    An example script to show how loosely PHP code can be written and
still work without any errors:
<?
error_reporting("E_ALL");
ob_start;
$h = time; // Literally prints 'time'
$i = time(); // Shows the current Unix Epoch time
$any_errors = ob_get_contents(); // Required, otherwise will be
literal 'ob_get_contents'
ob_end_clean;

echo($h."\n".$i."\n"); // echo is a construct, but as expected, can
use parentheses()

echo $any_errors."\n"; // Just in case there were errors in the buffer
(there aren't)....

die; // So in any case, whether function or construct, no parentheses
are required here.
?>

    Footnotes:
        1: I met a 'programmer' last night who had 'many years of
experience', who was a kid who looked like he just started college and
got his first 'puter.  He must've been 13373R than me, because he
argued with me for about 15 minutes that the languages themselves are
pronounced literally "FIPP" (PHP), "asp" (ASP), "gypsie" (JSP - yeah,
I know), and so on.  He argued to the point that he was calling me
profane names (while I laughed) as he said he has worked with the
'companies' that made the language.  When asked who created the 'FIPP'
language, he told me it was made by the Linux Corporation.  I'm not
exaggerating, I had to run to the bathroom because I was literally on
the verge of pissing myself.

-- 
</Dan>

Daniel P. Brown
Senior Unix Geek and #1 Rated "Year's Coolest Guy" By Self Since
Nineteen-Seventy-[mumble].

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux