Jump to content

including a php file using variables


adrumsolo4u

Recommended Posts

i want to include a php file, but have the function able to open a different file if one or both of the variables changes.

 

heres how it should work:

variable one is the folder

variable two is the file

 

include 'files/($var1)/($var2).php5';

 

how would i do this? i've looked, but nothing helps.

Link to comment
https://forums.phpfreaks.com/topic/40435-including-a-php-file-using-variables/
Share on other sites

going off of what you wrote:

include ($sub0 ."/". $sub0 .".php5");

 

gives me an error

 

Warning: include($sub0 ."/". $sub0 .".php5") [function.include]: failed to open stream: Invalid argument in C:\webs\index.php5 on line 5

 

Warning: include() [function.include]: Failed opening '$sub0 ."/". $sub0 .".php5"' for inclusion (include_path='.;C:\php5\pear') in C:\webs\index.php5 on line 5

 

 

i tried changing the characters ( and ) to ' '..which is how other includes are done

include '$sub0 ."/". $sub0 .".php5"';

 

but this gives me an error as well

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.