Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => General

How start php script in another php script

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

Postby DoppyNL » Wed Oct 16, 2002 4:09 am

Perhaps you can use this:
Code: Select all
if (condition) {
include('php_script_1.php');
}
else {
include('php_script_2.php');
}

include will simply execute the code in the place where is called.
see the manual for more details on include.
If you want on error to occur when te file is not found you can use the function require.

Greetz Daan
DoppyNL
 

Postby DoppyNL » Wed Oct 16, 2002 4:12 am

I forgot:

You cannot send headers when other data has allready been sent to the user because headers have to come first.
you can use the function ob_start() to start ouput-buffering wich will start buffering. That way you can sent headers later in you're script.
use the function ob_flush to send the data from that point, this function is automaticly called at the end of the script.

Greetz Daan
DoppyNL
 

Postby Jay » Wed Oct 16, 2002 1:24 pm

DoppyNL wrote:Perhaps you can use this:
Code: Select all
if (condition) {
include('php_script_1.php');
}
else {
include('php_script_2.php');
}

include will simply execute the code in the place where is called.
see the manual for more details on include.
If you want on error to occur when te file is not found you can use the function require.
Greetz Daan

Just to add to this, you can also use include_once() and require_once() if you only want a file included once through a script execution. If your scripts are anything like mine, it'll have multiple places where it can be inserted which will lead to problems, but using the _once parameter (or function rather) will ensure it'll only include the file once!
Jay
 


Return to PHP coding => General

Who is online

Users browsing this forum: No registered users and 2 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.