jm33990 Posted May 28, 2009 Share Posted May 28, 2009 inexperienced user does not see how to pass control to another php program with parameters. please advise..thx Quote Link to comment https://forums.phpfreaks.com/topic/160037-howto-call-another-php-program/ Share on other sites More sharing options...
Ken2k7 Posted May 28, 2009 Share Posted May 28, 2009 Huh? Please elaborate. Quote Link to comment https://forums.phpfreaks.com/topic/160037-howto-call-another-php-program/#findComment-844241 Share on other sites More sharing options...
BobcatM Posted May 28, 2009 Share Posted May 28, 2009 A program inside the same page, or on a different page, or? Please advise Quote Link to comment https://forums.phpfreaks.com/topic/160037-howto-call-another-php-program/#findComment-844243 Share on other sites More sharing options...
jm33990 Posted May 28, 2009 Author Share Posted May 28, 2009 not sure how to make it more clear...i'll try php program a finishes its processing and wishes to pass control to php program b with a few parameters. program b will output html using the passed parameters. Quote Link to comment https://forums.phpfreaks.com/topic/160037-howto-call-another-php-program/#findComment-844255 Share on other sites More sharing options...
shmoyko Posted May 28, 2009 Share Posted May 28, 2009 Maybe: header('location: program_b.php?par=1&par=2'); Or try reading about curl Quote Link to comment https://forums.phpfreaks.com/topic/160037-howto-call-another-php-program/#findComment-844257 Share on other sites More sharing options...
jm33990 Posted May 28, 2009 Author Share Posted May 28, 2009 header may work. not very clean though. I'm surprised that a modern programming language like php would not have a simple function to call/link to another php program. Quote Link to comment https://forums.phpfreaks.com/topic/160037-howto-call-another-php-program/#findComment-844269 Share on other sites More sharing options...
Ken2k7 Posted May 28, 2009 Share Posted May 28, 2009 What kind of PHP program is b? Can you put up an example in code? You're just not explaining the situation well. Quote Link to comment https://forums.phpfreaks.com/topic/160037-howto-call-another-php-program/#findComment-844270 Share on other sites More sharing options...
jm33990 Posted May 28, 2009 Author Share Posted May 28, 2009 just thinking at this point...I don't have any code. it will do as I said...construct and send html. the html is not static...part of it will include the parameters passed from program a Quote Link to comment https://forums.phpfreaks.com/topic/160037-howto-call-another-php-program/#findComment-844280 Share on other sites More sharing options...
elis Posted May 28, 2009 Share Posted May 28, 2009 It's difficult to understand what you're describing, it sounds like a function to me, though. Quote Link to comment https://forums.phpfreaks.com/topic/160037-howto-call-another-php-program/#findComment-844285 Share on other sites More sharing options...
jm33990 Posted May 28, 2009 Author Share Posted May 28, 2009 sounds like a function but it's not. a function, as I understand it, is calling code within the same program. Quote Link to comment https://forums.phpfreaks.com/topic/160037-howto-call-another-php-program/#findComment-844293 Share on other sites More sharing options...
Philip Posted May 28, 2009 Share Posted May 28, 2009 If it's a lot you are trying to pass to another script, look into the curl library and use a POST to the other script. Quote Link to comment https://forums.phpfreaks.com/topic/160037-howto-call-another-php-program/#findComment-844328 Share on other sites More sharing options...
ShadeSlayer Posted May 28, 2009 Share Posted May 28, 2009 What do you mean? You want to call code from file a to file b and execute it in file b? Are you looking for the "include()" tag, perhaps? Quote Link to comment https://forums.phpfreaks.com/topic/160037-howto-call-another-php-program/#findComment-844331 Share on other sites More sharing options...
corbin Posted May 28, 2009 Share Posted May 28, 2009 Edit: ShadeSlayer beat me to it, but posting anyway ;p. It also sounds like perhaps require would do the job. <?php $name = 'Corbin'; require 'ShowName.php'; ShowName.php <?php echo "Hello, $name!"; Quote Link to comment https://forums.phpfreaks.com/topic/160037-howto-call-another-php-program/#findComment-844333 Share on other sites More sharing options...
jm33990 Posted May 28, 2009 Author Share Posted May 28, 2009 I solved the problem using shmoyku's suggestion... header("location:reply.php?host=$hostname&ip=$ipaddr"); works perfectly I will also try the following later... exec("php reply.php -- arg1 arg2"); wondering if that will also do the trick.... Quote Link to comment https://forums.phpfreaks.com/topic/160037-howto-call-another-php-program/#findComment-844369 Share on other sites More sharing options...
Ken2k7 Posted May 28, 2009 Share Posted May 28, 2009 getopt Quote Link to comment https://forums.phpfreaks.com/topic/160037-howto-call-another-php-program/#findComment-844370 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.