View Full Version : require code question
Parker Clack
Sat 20th May '00, 5:48pm
If I wanted to require a .cgi file in one of the .php files would I just use:
require("/cgi-bin/myfile.cgi");
Thanks,
Parker
Mike Sullivan
Sat 20th May '00, 9:51pm
Nope - that will just display the script I believe.
You can use passthru - http://www.php.net/manual/function.passthru.php3 but when I tried that, it returned the "Content-type: text/html" line, and obviously I didn't want that, so I used this little code:
exec("/absolute/path/to/cgi/file", $test);
while(list($key,$val)=each($test)) {
if ($val!="Content-type: text/html") {
$test2 .= "$val";
}
}
echo "$test2";
Probably grossly inefficient, but it works...
Michael
Sun 21st May '00, 2:43pm
First of all I am not sure why you would want to include a .cgi in a PHP script - but requiring it shouldn't post it on the screen should it? If you "included" the file it would place text in the script, but require is different I think. I think that simply saying
require("/cgi-bin/myfile.cgi");
Does work. I would use the full path to the file though.
vBulletin® v3.8.0 Beta 1, Copyright ©2000-2008, Jelsoft Enterprises Ltd.