我想用php dom得到div里面的值,我用下面的代码得到了值,但是我没有得到它的php标签。 PHP DOM不解释标签,我知道PHP DOM不应该解释标签,但有没有解决标签的工作呢?php dom不解释php标签
$selected_div = "wrapper";
$file = 'http://localhost/jugni/selected.php'; // $file contents = <html><body><div id = "wrapper"><?php echo "hello world"; ?></div></body></html>
$file_get= file_get_contents($file);
$doc = new DomDocument("1.0", "utf-8");
$doc->loadHTML($file_get);
$element = $doc->getElementById($selected_div);
$existing_Data = $element->firstChild->nodeValue;
echo $existing_Data;
//echo $existing_Data gives me - hello world - , but what I want is the php tags with it as well , eg < ? php echo "hello world "; ?>
所以,实际上你希望在你的'$ file_get = file_get_contents($ file);'中有'<?php'和'?>'? – 2015-04-06 00:12:02
@测试,是的,有没有办法解决这个问题,<? PHP和? > – Manu 2015-04-06 00:27:33