dph987 Posted January 19, 2011 Share Posted January 19, 2011 hi gang, I just spent the better part of the day trying to find a way modularize my PHP code. I want to execute a php file and load the results into my main php program. I am not looking to include php source code into my prog and then execute it, I want to execute it and load the results into my prog. I know I can do this if I call a php file via apache: using file(http://ww.site.com/blah.php?parms) but is there a way to do it without using http ? The php file is local - in the same directory. I want something like this: $r = something.php?parms... how do I do this? regards, david Quote Link to comment https://forums.phpfreaks.com/topic/224945-breaking-php-code-into-modules/ Share on other sites More sharing options...
trq Posted January 19, 2011 Share Posted January 19, 2011 Kinda sounds like your fishing around for what is called the MVC pattern. This post..... http://www.phpfreaks.com/forums/application-design/fully-understanding-mvc-concept/msg729041/#msg729041 might help. Quote Link to comment https://forums.phpfreaks.com/topic/224945-breaking-php-code-into-modules/#findComment-1161820 Share on other sites More sharing options...
ignace Posted January 19, 2011 Share Posted January 19, 2011 but is there a way to do it without using http ? file('blah.php?parms') Quote Link to comment https://forums.phpfreaks.com/topic/224945-breaking-php-code-into-modules/#findComment-1161840 Share on other sites More sharing options...
Hattemageren Posted January 19, 2011 Share Posted January 19, 2011 $content = file_get_contents('somefile.php?param=blabla'); Should do the trick you're looking for Quote Link to comment https://forums.phpfreaks.com/topic/224945-breaking-php-code-into-modules/#findComment-1161886 Share on other sites More sharing options...
ignace Posted January 19, 2011 Share Posted January 19, 2011 but is there a way to do it without using http ? file('blah.php?parms') Oeps, I posted this prematurely. Yes, this will only work through HTTP or CLI: php blah.php params1 params2 params3 Quote Link to comment https://forums.phpfreaks.com/topic/224945-breaking-php-code-into-modules/#findComment-1162056 Share on other sites More sharing options...
AbraCadaver Posted January 19, 2011 Share Posted January 19, 2011 Building on ignace's post: exec('blah.php data data2', $output); //or exec('blah.php --arg=data --arg2=data2', $output); Then use $argc and $argv in blah.php to get values. $output contains blah.php output. Quote Link to comment https://forums.phpfreaks.com/topic/224945-breaking-php-code-into-modules/#findComment-1162066 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.