I've got an ajax call returning some html. The html is created and returned in a function like so:
function return_html(){
$title = 'My Form';
$returnObject = array();
$returnObject['html'] = '
<form>
<h1>' . $title . '</h1>
<input type="text" name="title"/>
</form>
';
return json_encode($returnObject);
}
What I'd like to do is write a .php file with all of my html and vars in it like this...
<form>
<h1><?php echo $title ?></h1>
<input type="text" name="title"/>
</form>
and then in my function import that file as a string with the vars set sorta like this:
function return_html(){
$title = 'My Form';
$returnObject = array();
$returnObject['html'] = my_file_as_string_but_with_vars_replaced('formFile.php');
return json_encode($returnObject);
}
Thoughts?