jj0b Posted March 14, 2008 Share Posted March 14, 2008 Hello, I am trying to pass a variable as an argument to the include() function. for example in my index.html file I have this: $var = "\"page.html\""; include($var); This does not work even though the following does work: include("page.html"); page.html is in the same directory as index.html. These are the error messages that I get: Warning: include("page.html") [function.include]: failed to open stream: No such file or directory in /home/username/public_html/index.html on line 27 Warning: include() [function.include]: Failed opening '"page.html"' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/username/public_html/index.html on line 27 Does anyone know what would cause these errors? Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/96106-variable-argument-in-include/ Share on other sites More sharing options...
Daniel0 Posted March 14, 2008 Share Posted March 14, 2008 Do $var = "page.html"; instead. Otherwise the filename would literally have to start and end with a double quote which is not possible. Quote Link to comment https://forums.phpfreaks.com/topic/96106-variable-argument-in-include/#findComment-491996 Share on other sites More sharing options...
jj0b Posted March 14, 2008 Author Share Posted March 14, 2008 Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/96106-variable-argument-in-include/#findComment-492265 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.