Results 1 to 3 of 3

Thread: [INFORMATIVE] Header() Redirect

  1. #1

    Thread Starter
    Frenzied Member TheBigB's Avatar
    Join Date
    Mar 2006
    Location
    *Stack Trace*
    Posts
    1,511

    [INFORMATIVE] Header() Redirect

    Hi all,

    Today I've been busy with a redirection page.
    I got into a conflict when I tried to redirect it halfway my page.
    As it was hard to recode everything to the top, I looked up a solution and I'd like to share it with you, as I've seen many threads here where this isn't mentioned.

    I'm talking about the ob_start and ob_end_flush functions.
    It works great for me.
    Now I'm pretty sure you know those functions exist.
    Why don't you use/advise them?
    Delete it. They just clutter threads anyway.

  2. #2
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: [INFORMATIVE] Header() Redirect

    Because it's better practice to work out whether or not you need to redirect or not before beginning any output.

    All processing logic should be completed before output logic begins.

    Output buffers have their uses but avoiding the problems associated with spaghetti logic or non-decoupled processing/output is not what they are for.

  3. #3
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256

    Re: [INFORMATIVE] Header() Redirect

    The issue could be better solved by breaking up your application logic and your view logic -- meaning all code should be processed before you output anything.

    This can be accomplished using the MVC (model-view-controller) architecture or using templating.

    Using the output buffering, like penagate said, is a hack to make bad code work.
    My evil laugh has a squeak in it.

    kristopherwilson.com

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width