Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Redirect

Status
Not open for further replies.

mickallen

Technical User
Jan 5, 2001
39
GB
I'am wanting to execute a php script from within another php script for example:

if (action == 0){
script1.php
}

I know I can use include to include the script but this would not work for what I'am wanting to do.

 
If you are using Apache as your web server, you can use the Virtual() function. This function performs an Apache sub request simmular to <!--#include virtual...--> in the mod_include Apache module.
Code:
if (action == 0){
    virtual(&quot;/path/to/script/script1.php&quot;)
   }
If you are not using Apache and &quot;URL fopen wrappers&quot; are enabled in PHP you can include a file with a URL instead of a local path name, thus causing the include() function to retrieve the results of a PHP script instead of the script itself.
Code:
if (action == 0){
    include(&quot;[URL unfurl="true"]http://www.yourdomain.com/path/to/script/script1.php&quot;)[/URL]
   }
OR
Code:
if (action == 0){
    include(&quot;[URL unfurl="true"]http://localhost/path/to/script/script1.php&quot;)[/URL]
   }
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top