echoing a php string with a wordpress include
with the following code
<?php
if (qtrans_getLanguage() == "en") {
echo <?php include( TEMPLATEPATH . '/slider_en.php' ); ?>;
}else{
echo <?php include( TEMPLATEPATH . '/slider_de.php' ); ?>;
}
?>
i'm trying to include a file, based on the chosen language of the website. guess my idea is right but i'm totaly wrong on the syntax of using include in an echo..
can someone please开发者_开发问答 oint me in the right direction?
many thanks,
tobi.
You are already in PHP mode, so you don't need to re-open the PHP tags (<?php
). Remove them, and it should work. You don't even need the echo
, since PHP drops out of PHP mode and back in HTML mode when it includes a file.
<?php
if (qtrans_getLanguage() == "en") {
include( TEMPLATEPATH . '/slider_en.php' );
} else {
include( TEMPLATEPATH . '/slider_de.php' );
}
?>
You can't echo an include. Try just including the file, otherwise you can try the get_file_contents function, which returns the file as a string.
echo get_file_contents( TEMPLATEPATH . '/slider_de.php');
More info on get_file_contents: http://php.net/manual/en/function.file-get-contents.php
精彩评论