Skip to content

Instantly share code, notes, and snippets.

@narita1980
Last active December 15, 2015 18:49
Show Gist options
  • Save narita1980/5307141 to your computer and use it in GitHub Desktop.
Save narita1980/5307141 to your computer and use it in GitHub Desktop.
元の状態を維持したまま解析をする(str_get_html)
<?php
require_once('classes/simple_html_dom.php');
$str = <<<EOT
<html>
<head></head>
<body>This is a test.</body>
</html>
EOT;
$html = str_get_html($str);
echo "[sample1]\n";
echo $html . "\n\n";
$html = str_get_html($str, true, true, DEFAULT_TARGET_CHARSET, false);
echo "[sample2]\n";
echo $html . "\n\n";
/*****
Output:
[sample1]
<html> <head></head> <body>This is a test.</body> </html>
[sample2]
<html>
<head></head>
<body>This is a test.</body>
</html>
*****/
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment