Hi all Quick question, its stumped me, so am hoping someone can help. If I want to include a file by way of PHP include, so I would have the following <?php include (TEMPLATEPATH.'/scripts/comment-templates/FILENAME.php');?> Code (markup): So that works. Now I want to have FILENAME as a variable. So its been set though a different array (it works, I can echo the name correctly with this) $mb_comment_template_name Code (markup): How can I join those together? So $mb_comment_template_name replaces FILENAME in the include lines. I cant get it to read the variable, it just spits out the variable name not its value. Thanks to anyone who can help!!!
<?php include (TEMPLATEPATH."/scripts/comment-templates/$mb_comment_template_name.php");?> That should replace FILENAME with $mb_comment_template_name. You cannot use $variables in a string enclosed with ' and '. It needs to be " and ". If you wanted to use ' and ', you could use the following: <?php include (TEMPLATEPATH.'/scripts/comment-templates/'.$mb_comment_template_name.'.php');?>
yes thats right. So I can define the value of $mb_comment_template_name somewhere else on the site. So if I defined it as "melon" the file location would come back as: <?php include (TEMPLATEPATH.'/scripts/comment-templates/melon.php');?> Its gonna be a different value due to user selections, so I cant just hard copy it in. Hope that makes sense!