Jump to content

[SOLVED] Is there a way to do this


dhimok

Recommended Posts

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

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>

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.