Q: Use PHP to include an HTML file as a jQuery object Let's say I have a "test.html" file with some example content:
<table>
 <tr>
  <td>'Test'</td>
  <td>Test "2"</td>
 </tr>
</table>

And I want to use that as a jQuery object.  My first instinct would be to attempt:
var $testobject = $("<?php include('./test.html');?>");

But with the line breaks and quotes in test.html, this would fail.  I specifically need the test.html file to be a jQuery object so it is hidden on load and is put in different places on the page with various triggered scripts, and I would prefer to use the more static PHP approach than a jQuery load.  There must be a simple trick to manage this...

A: Read the static file using file_get_contents, and deal with special characters using json_encode:
var $testobject = $(<?php echo json_encode(file_get_contents('./test.html'));?>);

For example, if test.html contains:
<a href="/">
  Test
</a>

Then the output will be:
var $testobject = $("<a href=\"\/\">\n  Test\n<\/a>\n");


A: use load :
create a div 
$('#test').load('test.html');

var testObject = $('#div').find('table');

A: use output buffering:
<?php
ob_start();
include('./test.html');
$data = ob_get_contents();
ob_end_clean();
?>

var $testobject = $("<?=$data;?>");

