require code question

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Parker Clack
    Senior Member
    • Apr 2000
    • 367

    require code question

    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
    Former vBulletin Developer
    • Apr 2000
    • 13327
    • 3.6.x

    #2
    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:
    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...

    Comment

    • Michael
      Member
      • Apr 2000
      • 65

      #3
      You sure?

      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.
      Michael Bray

      Comment

      widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
      Working...