Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.php > #14862
| From | Jerry Stuckle <jstucklex@attglobal.net> |
|---|---|
| Newsgroups | comp.lang.php |
| Subject | Re: PHP CSV |
| Date | 2015-02-04 10:57 -0500 |
| Organization | A noiseless patient Spider |
| Message-ID | <matffs$6go$1@dont-email.me> (permalink) |
| References | (12 earlier) <54d20e47$0$2897$e4fe514c@news2.news.xs4all.nl> <mat59b$qn4$1@dont-email.me> <040220151329007325%timstreater@greenbee.net> <mat90n$af9$1@dont-email.me> <54d23d2c$0$2882$e4fe514c@news2.news.xs4all.nl> |
On 2/4/2015 10:39 AM, Erwin Moller wrote:
> On 2/4/2015 3:06 PM, Jerry Stuckle wrote:
>> On 2/4/2015 8:29 AM, Tim Streater wrote:
>>> In article <mat59b$qn4$1@dont-email.me>, Jerry Stuckle
>>> <jstucklex@attglobal.net> wrote:
>>>
>>>> On 2/4/2015 7:19 AM, Erwin Moller wrote:
>>>>> On 12/19/2014 4:59 PM, Jerry Stuckle wrote:
>>>
>>>>>> return does not create invalid output. die() and exit() do.
>>>>>>
>>>>>> I have *never* found a need for either one in a properly constructed
>>>>>> script.
>>>
>>>>> I use exit() after a header location combi.
>>>>>
>>>>> if (whatever){
>>>>> dostuff();
>>>>> header("location: ....");
>>>>> exit;
>>>>> }
>>>>>
>>>>> It is an easy way to redirect, and terminate the script, and not
>>>>> having
>>>>> a (possibly huge) else-part.
>>>>>
>>>>> Do you (Jerry) think that that approach isn't properly?
>>>>> If so, why?
>>>
>>>> With a properly constructed script, you don't need to call exit() after
>>>> a header() call, either.
>>>
>>> I use exit when processing is complete. Sometimes that happens inside
>>> an "if" or other construct.
>>>
>>> I certainly don't intend, ever, to use convoluted if/then/else just so
>>> that processing always arrives at the last line of a script.
>>>
>>
>> Which terminates processing immediately - and anything after that point
>> (such as </BODY> and </HTML> tags is not sent to the browser. This
>> causes an invalid page to be generated.
>>
>> Do your clients know you're generating invalid HTML for them?
>>
>
> In my above example, the script did something useful in doStuff();
> Then, redirects to another page with the header("location: ....").
>
> I never intended to give the idea my example was outputting HTML to a
> browser (but should have said so to avoid confusion).
>
> I often use PHP to processing some posting/do some task, and when
> finished, set header/location to another page. (That will also avoid
> the dreaded back-button/formpost confirmation that confuses most
> non-webprogrammers = 99.9% of the world).
>
> So using exit() seems completely valid to me.
>
> For clarity's sake: I dislike half-finished HTML too, just like you, and
> when the script produces output, it *should* finish the document in a
> valid way. No discussion there.
>
> You just triggered me by your statement that you never use exit(), when
> you program properly.
> I use exit for the very reason Tim Steater gave: to avoid too much code
> into if-then-else constructs, for the sake of finishing at some point at
> the end.
> IMHO it makes the script less readable.
>
> Regards,
> Erwin Moller
>
> PS: If in your opinion only MVC is proper programming, than I can see
> why you never encounter exit() anymore.
>
I never do use exit(). There is no need for it, even in your example.
Proper code structure eliminates the problem. Structured programming
does not make code less readable, if it's done properly. And it does
make the code more maintainable. You don't have to, for instance, try
to analyze a bunch of code to determine why your change did not take
effect - because you had already exited the code earlier.
I've just seen too many problems in other languages such as C/C++ caused
by people not wanting to structure their code properly with if-then-else
statements - and the problems it can cause.
--
==================
Remove the "x" from my email address
Jerry Stuckle
jstucklex@attglobal.net
==================
Back to comp.lang.php | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
PHP CSV Joydeep Chakrabarty <chalao.adda@gmail.com> - 2014-12-18 17:09 +0530
Re: PHP CSV Markus Heinz <markus.heinz@uni-dortmund.de> - 2014-12-18 13:11 +0100
Re: PHP CSV "Christoph M. Becker" <cmbecker69@arcor.de> - 2014-12-18 13:27 +0100
Re: PHP CSV Joydeep Chakrabarty <chalao.adda@gmail.com> - 2014-12-18 18:26 +0530
Re: PHP CSV Markus Heinz <markus.heinz@uni-dortmund.de> - 2014-12-18 14:43 +0100
Re: PHP CSV Jerry Stuckle <jstucklex@attglobal.net> - 2014-12-18 09:24 -0500
Re: PHP CSV Joydeep Chakrabarty <chalao.adda@gmail.com> - 2014-12-18 20:56 +0530
Re: PHP CSV Markus Heinz <markus.heinz@uni-dortmund.de> - 2014-12-18 16:57 +0100
Re: PHP CSV "Christoph M. Becker" <cmbecker69@arcor.de> - 2014-12-18 17:04 +0100
Re: PHP CSV Joydeep Chakrabarty <chalao.adda@gmail.com> - 2014-12-18 21:52 +0530
Re: PHP CSV Markus Heinz <markus.heinz@uni-dortmund.de> - 2014-12-18 17:38 +0100
Re: PHP CSV Joydeep Chakrabarty <chalao.adda@gmail.com> - 2014-12-18 16:49 +0000
Re: PHP CSV Jerry Stuckle <jstucklex@attglobal.net> - 2014-12-18 21:34 -0500
Re: PHP CSV Tim Streater <timstreater@greenbee.net> - 2014-12-19 09:43 +0000
Re: PHP CSV "Christoph M. Becker" <cmbecker69@arcor.de> - 2014-12-19 14:05 +0100
Re: PHP CSV Jerry Stuckle <jstucklex@attglobal.net> - 2014-12-19 10:59 -0500
Re: PHP CSV Matthew Carter <m@ahungry.com> - 2014-12-19 14:21 -0500
Re: PHP CSV Jerry Stuckle <jstucklex@attglobal.net> - 2014-12-19 18:17 -0500
Re: PHP CSV "M. Strobel" <sorry_no_mail_here@nowhere.dee> - 2014-12-20 00:35 +0100
Re: PHP CSV Erwin Moller <erwinmollerusenet@xs4all.nl> - 2015-02-04 13:19 +0100
Re: PHP CSV Jerry Stuckle <jstucklex@attglobal.net> - 2015-02-04 08:03 -0500
Re: PHP CSV Tim Streater <timstreater@greenbee.net> - 2015-02-04 13:29 +0000
Re: PHP CSV Jerry Stuckle <jstucklex@attglobal.net> - 2015-02-04 09:06 -0500
Re: PHP CSV Tim Streater <timstreater@greenbee.net> - 2015-02-04 15:26 +0000
Re: PHP CSV Jerry Stuckle <jstucklex@attglobal.net> - 2015-02-04 10:40 -0500
Re: PHP CSV Paul Herber <paul@pherber.com> - 2015-02-04 16:11 +0000
Re: PHP CSV Jerry Stuckle <jstucklex@attglobal.net> - 2015-02-04 11:23 -0500
Re: PHP CSV Tim Streater <timstreater@greenbee.net> - 2015-02-04 17:08 +0000
Re: PHP CSV Jerry Stuckle <jstucklex@attglobal.net> - 2015-02-04 12:48 -0500
Re: PHP CSV Tim Streater <timstreater@greenbee.net> - 2015-02-04 17:05 +0000
Re: PHP CSV Jerry Stuckle <jstucklex@attglobal.net> - 2015-02-04 12:49 -0500
Re: PHP CSV Tim Streater <timstreater@greenbee.net> - 2015-02-04 18:14 +0000
Re: PHP CSV Jerry Stuckle <jstucklex@attglobal.net> - 2015-02-04 13:37 -0500
Re: PHP CSV Matthew Carter <m@ahungry.com> - 2015-02-04 15:23 -0500
Re: PHP CSV "Christoph M. Becker" <cmbecker69@arcor.de> - 2015-02-04 21:54 +0100
Re: PHP CSV Jerry Stuckle <jstucklex@attglobal.net> - 2015-02-04 16:32 -0500
Re: PHP CSV Jerry Stuckle <jstucklex@attglobal.net> - 2015-02-04 16:31 -0500
Re: PHP CSV Erwin Moller <erwinmollerusenet@xs4all.nl> - 2015-02-04 16:39 +0100
Re: PHP CSV Jerry Stuckle <jstucklex@attglobal.net> - 2015-02-04 10:57 -0500
Re: PHP CSV Erwin Moller <erwinmollerusenet@xs4all.nl> - 2015-02-04 18:07 +0100
Re: PHP CSV Jerry Stuckle <jstucklex@attglobal.net> - 2015-02-04 12:55 -0500
Re: PHP CSV Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-02-06 23:26 +0100
Re: PHP CSV "Christoph M. Becker" <cmbecker69@arcor.de> - 2015-02-07 01:38 +0100
Re: PHP CSV Jerry Stuckle <jstucklex@attglobal.net> - 2015-02-06 19:44 -0500
Re: PHP CSV "Christoph M. Becker" <cmbecker69@arcor.de> - 2015-02-07 14:49 +0100
Re: PHP CSV Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-02-07 14:28 +0100
Re: PHP CSV Jerry Stuckle <jstucklex@attglobal.net> - 2015-02-06 19:42 -0500
Re: PHP CSV "Christoph M. Becker" <cmbecker69@arcor.de> - 2015-02-07 04:33 +0100
Re: PHP CSV Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-02-07 14:26 +0100
Re: PHP CSV "Christoph M. Becker" <cmbecker69@arcor.de> - 2015-02-07 14:45 +0100
Re: PHP CSV Jerry Stuckle <jstucklex@attglobal.net> - 2015-02-07 08:54 -0500
Re: PHP CSV "Christoph M. Becker" <cmbecker69@arcor.de> - 2015-02-07 16:54 +0100
Re: PHP CSV Jerry Stuckle <jstucklex@attglobal.net> - 2015-02-07 11:00 -0500
Re: PHP CSV Jerry Stuckle <jstucklex@attglobal.net> - 2015-02-07 08:51 -0500
Re: PHP CSV "Christoph M. Becker" <cmbecker69@arcor.de> - 2015-02-07 14:55 +0100
Re: PHP CSV Olaf Schmitt <thesys@gmx.de> - 2014-12-19 01:16 +0100
Re: PHP CSV Denis McMahon <denismfmcmahon@gmail.com> - 2014-12-19 02:14 +0000
Re: PHP CSV Joydeep Chakrabarty <chalao.adda@gmail.com> - 2014-12-18 18:13 +0530
Re: PHP CSV Derek Turner <frderek@cesmail.net> - 2014-12-18 12:55 +0000
Re: PHP CSV Joydeep Chakrabarty <chalao.adda@gmail.com> - 2014-12-18 18:33 +0530
Re: PHP CSV Derek Turner <frderek@cesmail.net> - 2014-12-18 13:10 +0000
Re: PHP CSV Jerry Stuckle <jstucklex@attglobal.net> - 2014-12-18 08:17 -0500
Re: PHP CSV "Christoph M. Becker" <cmbecker69@arcor.de> - 2014-12-18 15:16 +0100
csiph-web