Jump to content

Need Help on passing var between PHP <----> CGI


madThumbs

Recommended Posts

Hey guys, I really need help on this passing value to CGI and get value back to PHP stuff work. Big Thanks

 

Ok Here is my current code:

 

PHP Code:

<?php

ob_start();
    	passthru ("/usr/local/etc/httpd/htdocs/XXXX/testing.cgi");
    	$results = ob_get_contents();
    	ob_end_clean();
    	echo $results;	

?>

 

and Here is my CGI Code:

 

#!/usr/bin/perl -wT

sub test {

  my @n;
  $n[0] = 10;
  $n[1] = 17;
  $n[2] = 23;
  return @n;
  }

($first,$second,$third) = test();


print "$first-$second-$third";

 

If I run the code above I got this: 10-17-23

 

!!!! BIG HOWEVER !!!!!

 

I would like to pass a value $myNumber to $n[0];

 

simple say the result I hope is: 

 

if I set $myNumber = 10000

 

then I got this: 10000-17-23

 

The reason passing and retrieving value from CGI is, I need pass a value into a CGI function (large and complex function, no time to convert to php) and get the return of that CGI function and use it in the PHP script.

 

And this may make it easier to under stand:

------------------------------------------

#!/usr/bin/perl -wT

sub test {

my @n;
$n[0] = $mySuperNumber(Somehow pass this value from php and use here);
$n[1] = 17;

$c = $n[0] + $n[1];

return $c;

}

($NewResult) = test();

print "$NewResult";

----------------------------------------------

 

Then I can use the php code above to get the value of this $NewResult

 

Am I make myself clear?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.