Forum Moderators: coopster

Message Too Old, No Replies

How can I invoke a php script from within another

invoking php scripts within another php script

         

mikejson

1:28 am on Oct 13, 2004 (gmt 0)

10+ Year Member



Hi,

I have built 2 scripts.

1. checks the status of something, and runs script 2 if nessacary.

2. does an xml import.

I want to be able to get the "check status" script to call this "xml import" script if a certain condition is met, I also want my user to be able to "force" the "xml import" whenever they want.

Basically, I don't want to have to write the code in "xml import" again in "check status".

Is there a way that I don't have to repeat the code?

mikejson

2:40 am on Oct 13, 2004 (gmt 0)

10+ Year Member



using the header() function does not work as the location I'm to has repeated function names in it(because they use a common include), so does the include(), virtual(), all do the same thing. They error out cause both scripts contain a common include(namely a session handler etc, that I've build generic functions to use in all my pages). It is not possible to remove the common include in all the pages(way to much work).

I'm going to look into the script having a function getXMLData(); and see if I can include that script, which has the common include in it, then call the scripts functions.... Im grasping at straws though.

Code Sentinel

3:28 am on Oct 13, 2004 (gmt 0)

10+ Year Member



I like to keep things simple.. so my only advice is:

if (condition)
include('importscript.php');

as for your common include issue..dunno.. perhaps put a conditional in the importscript to check for the session handler so it doesn't include if called from the "check status" script.

this is assuming the import script does't require any input of any type because it would just do its thing and finish (import, clean up, end).

SofterLogic UK

11:40 am on Oct 13, 2004 (gmt 0)

10+ Year Member



Read up on:
include(); include_once();
require(); require_once();

Also:
file_get_contents();
fopen(); fread(); fclose();