• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1245
  • Last Modified:

PHP forward without using header

Is there a way to pass control from one php doc to another? I'm trying to achieve a similar programming style in php that I'm familiar with in java. I want to take the result of such and such then push them to a different page without using the header function. In java you can forward the response object to another class such as a jsp or a servlet.

Thanks
0
wgordy
Asked:
wgordy
  • 4
  • 2
1 Solution
 
BatalfCommented:
No, you have to use javascript or HTML to do that

Javascript

<script type="text/javascript">
location.href='newPage.html';
</script>
<?php
exit;
?>

or HTML

<META HTTP-EQUIV="Refresh"
      CONTENT="0; URL=newPage.html">
0
 
wgordyAuthor Commented:
Thanks, I was hoping there was a way to pass on the server side and not envolve the client. Oh well.
0
 
BatalfCommented:
Why can't you use the header() function?

What you could do is to buffer the content at the start of your file

ob_start();

and then flush it below the part where you send people to another site with the header("location:.... ) statement

ob_end_flush();
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
virmaiorCommented:
there's another option

include 'mysecondfile.php'; exit(0);
0
 
BatalfCommented:
To use include for a redirect sounds dangerous.

Batalf
0
 
wgordyAuthor Commented:
it's not a redirect with the client. It's a process control transfer. It's MVC architecture.
0
 
BatalfCommented:
Sorry, misread your question. Great that it's solve though.

Batalf
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now