dhimok Posted April 13, 2007 Share Posted April 13, 2007 Hello everyone. I have an external file, it s plain html and I need to print this file in a function where i am using return not echoing. Is there any way to assign a variable to hold the code of the external html file? It s more like a template html file $str = myFunction(); echo $str; Thanks in advance Link to comment https://forums.phpfreaks.com/topic/46919-solved-is-there-a-way-to-do-this/ Share on other sites More sharing options...
Guest prozente Posted April 13, 2007 Share Posted April 13, 2007 http://us2.php.net/manual/en/function.file-get-contents.php Link to comment https://forums.phpfreaks.com/topic/46919-solved-is-there-a-way-to-do-this/#findComment-228766 Share on other sites More sharing options...
dhimok Posted April 13, 2007 Author Share Posted April 13, 2007 thanks Link to comment https://forums.phpfreaks.com/topic/46919-solved-is-there-a-way-to-do-this/#findComment-228771 Share on other sites More sharing options...
dhimok Posted April 13, 2007 Author Share Posted April 13, 2007 Ok, inside that file I have a some constants from a language file and it cannot be printed or it return no value. How can I make this possible Link to comment https://forums.phpfreaks.com/topic/46919-solved-is-there-a-way-to-do-this/#findComment-228778 Share on other sites More sharing options...
Guest prozente Posted April 13, 2007 Share Posted April 13, 2007 Provide some sample data and code so I can get a better picture of exactly what you're trying. Link to comment https://forums.phpfreaks.com/topic/46919-solved-is-there-a-way-to-do-this/#findComment-228783 Share on other sites More sharing options...
dhimok Posted April 13, 2007 Author Share Posted April 13, 2007 Ok here I have the function function pageContent() { $retval = ""; $sql = "SELECT category_id, parent, category, body, descr, keywords FROM " . TABLE_CATEGORIES . " WHERE category_id = '" . GET_C . "'"; $res = dbQuery($sql) or die(mysql_error()); list($id, $parent, $cat, $body, $descr, $keywords) = dbFetchArray($res, MYSQL_BOTH); switch($cat) { case 'new': $retval .= file_get_contents("tools/new.php"); break; default: $retval .= $body; } return $retval; } and here s the external file <div id="tools"> <form action="" method="post"> <div><?=LANG_PAGE_NAME?> <span>*</span></div> <input type="text" name="category" /> <div><?=LANG_PAGE_TITLE?></div> <input type="text" name="title" /> <div><?=LANG_PAGE_DESCR?></div> <textarea name="descr"></textarea> </form> </div> Link to comment https://forums.phpfreaks.com/topic/46919-solved-is-there-a-way-to-do-this/#findComment-228788 Share on other sites More sharing options...
Guest prozente Posted April 13, 2007 Share Posted April 13, 2007 You originally said the file was plaintext html.. You would instead need to use something like ob_start(); require('filename.html'); $output = ob_get_contents(); ob_end_clean(); Link to comment https://forums.phpfreaks.com/topic/46919-solved-is-there-a-way-to-do-this/#findComment-228790 Share on other sites More sharing options...
dhimok Posted April 13, 2007 Author Share Posted April 13, 2007 yeah, the last minute i thought i will need some constants there. Thanks for ur help, it worked well Link to comment https://forums.phpfreaks.com/topic/46919-solved-is-there-a-way-to-do-this/#findComment-228805 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.