Forum Moderators: coopster
I'm using the following include
<?php include 'includes/I_searchbox.txt';?> which is fine, but I want to include a variable ($ty_dir) in the include but I cant figure out the correct syntax to make it work
ie say $ty_dir = 'http://www.mysite.com/thisyearsdirectory/';
then I want PHP include that calls
[mysite.com...]
I've tried
<?php include $ty_dir'includes/I_searchbox.txt';?> [edited by: jatar_k at 5:51 pm (utc) on Jan. 4, 2004]
[edit reason] fixed the bbcodes [/edit]
In case you don't know why... Your last version works because you have put a concatenation operator (.) between your variable and your literal string. That is what makes it work.
One good thing to do if your include doesn't work is to echo it (replace 'include' with 'echo') and see if the string it prints is the name of the file or not.