One script passing control to the other?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Pawel Halastra FrT

    #1

    One script passing control to the other?

    Elo,
    I'm having a terrible trouble with a simple, as I think, issue. I need
    to stop my script in the middle of proccesing, and, simultanously, start
    a new script. The idea is not to sent any output to web browser before
    the second script is done. Typical scenario should goes like this:
    - script a.php ends its execution with some error, instead of sending
    its output to the browser, a.php passes control to b.php
    - output is being cleared, script b.php renders it from scratch, then
    sends back to the browser

    Is it possible (like in ASP.NET lets say - Server.Redirect ())?

    Many thanks for help!

    --
    Pawel Halastra 'FrT'
  • ZeldorBlat

    #2
    Re: One script passing control to the other?


    Pawel Halastra FrT wrote:
    Elo,
    I'm having a terrible trouble with a simple, as I think, issue. I need
    to stop my script in the middle of proccesing, and, simultanously, start
    a new script. The idea is not to sent any output to web browser before
    the second script is done. Typical scenario should goes like this:
    - script a.php ends its execution with some error, instead of sending
    its output to the browser, a.php passes control to b.php
    - output is being cleared, script b.php renders it from scratch, then
    sends back to the browser
    >
    Is it possible (like in ASP.NET lets say - Server.Redirect ())?
    >
    Many thanks for help!
    >
    --
    Pawel Halastra 'FrT'
    header('Locatio n: b.php');

    Comment

    • Pawel Halastra FrT

      #3
      Re: One script passing control to the other?

      ZeldorBlat wrote:
      header('Locatio n: b.php');
      >
      Thanks, but this is totally not what I'm looking for.

      header('Locatio n: b.php') will send back the output to the browser, then
      the browser will require "b.php", so unnecesary post-back is performed.

      --
      Pawel Halastra 'FrT'

      Comment

      • Rik

        #4
        Re: One script passing control to the other?

        Pawel Halastra FrT wrote:
        Elo,
        I'm having a terrible trouble with a simple, as I think, issue. I need
        to stop my script in the middle of proccesing, and, simultanously,
        start a new script. The idea is not to sent any output to web browser
        before the second script is done. Typical scenario should goes like
        this: - script a.php ends its execution with some error, instead of
        sending its output to the browser, a.php passes control to b.php
        - output is being cleared, script b.php renders it from scratch, then
        sends back to the browser
        >
        Is it possible (like in ASP.NET lets say - Server.Redirect ())?
        >
        Many thanks for help!
        Well, unless there are fatal errors in a.php, use the output buffering
        functions (ob_start() in a.php, ob_end_clean() in b.php).

        When there are fatal errors in a.php it's somewhat trickier. You might want
        to use set_error_handl er() for this one, but be very sure what you're
        doing. It will still not be able to catch every error though...
        --
        Rik Wasmus


        Comment

        • Hendri Kurniawan

          #5
          Re: One script passing control to the other?

          Road on ob_start, ob_flush, ob_clean..... and ob related function.
          I often redirect my script as well, but I do it simply by including that
          file.

          Example:
          if(!@statement a) {
          include('b.php' );
          exit();
          }

          PS: BTW the @ sign is to suppress the error msg. And bare in mind that
          this is a simple
          example. There are more better way to handle error.

          Hendri Kurniawan

          Pawel Halastra FrT wrote:
          Elo,
          I'm having a terrible trouble with a simple, as I think, issue. I need
          to stop my script in the middle of proccesing, and, simultanously, start
          a new script. The idea is not to sent any output to web browser before
          the second script is done. Typical scenario should goes like this:
          - script a.php ends its execution with some error, instead of sending
          its output to the browser, a.php passes control to b.php
          - output is being cleared, script b.php renders it from scratch, then
          sends back to the browser
          >
          Is it possible (like in ASP.NET lets say - Server.Redirect ())?
          >
          Many thanks for help!
          >
          --
          Pawel Halastra 'FrT'

          Comment

          Working...