johnnyk Posted July 3, 2006 Share Posted July 3, 2006 Is it possible to do something like this:require('whatever.inc?id=1'); Link to comment https://forums.phpfreaks.com/topic/13511-require-with-variables/ Share on other sites More sharing options...
zq29 Posted July 3, 2006 Share Posted July 3, 2006 Unfortunatly not. Depending on what it is you wish to include, you could use an iframe, it's src attribute will accept files with variables appended to them. Link to comment https://forums.phpfreaks.com/topic/13511-require-with-variables/#findComment-52465 Share on other sites More sharing options...
johnnyk Posted July 3, 2006 Author Share Posted July 3, 2006 Is there a reason PHP doesn't let you do that. Seems like it would be pretty useful. Link to comment https://forums.phpfreaks.com/topic/13511-require-with-variables/#findComment-52548 Share on other sites More sharing options...
kenrbnsn Posted July 3, 2006 Share Posted July 3, 2006 These functions just make it easier to insert chunks of code into the code stream. Any variables that are defined before the included code are available to be used by the included code.Ken Link to comment https://forums.phpfreaks.com/topic/13511-require-with-variables/#findComment-52551 Share on other sites More sharing options...
johnnyk Posted July 3, 2006 Author Share Posted July 3, 2006 But what if I want to modify what is included, for example:require('whatever.php?id=1');whatever.php[code]switch($_GET['id']){case '1': echo 'echo this'; break;case '2': echo 'echo that'; break;}[/code]That seems useful. Is there any way to do something like that? Link to comment https://forums.phpfreaks.com/topic/13511-require-with-variables/#findComment-52558 Share on other sites More sharing options...
redarrow Posted July 3, 2006 Share Posted July 3, 2006 use a function() { } one one page.then include("the page") then call that function() ok. Link to comment https://forums.phpfreaks.com/topic/13511-require-with-variables/#findComment-52560 Share on other sites More sharing options...
johnnyk Posted July 3, 2006 Author Share Posted July 3, 2006 What would the function do? Could you give some example code? Link to comment https://forums.phpfreaks.com/topic/13511-require-with-variables/#findComment-52564 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.