脚本宝典收集整理的这篇文章主要介绍了php – 如何使用SimpleHtmlDom在HTML标题上的头标记之间插入链接标记,脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
<link href="style.css" rel="stylesheet" tyPE="text/css" />
头部标签之间?
<?PHP # create and load the HTML include('simple_html_dom.PHP'); // get DOM From URL or file $html = file_get_html('D:\xampp\htdocs\solofile\index.html'); $indexFile ='index.PHP'; $openIndexFile = fopen($indexFile,'a'); //find head tag foreach($html->find('head') as $e) { $findHead = $e->outertext; fwrITe($openIndexFile,"\n" .$findHead. "\n"); }
// Append a element $e->outertext = $e->outertext . '<div>foo<div>';
您可以这样使用:
$e = $html->find('head')->innertext; // Should take all HTML inside <head></head> w/o <head></head $e = $e.'<link href="style.css" rel="stylesheet" type="text/css" />'; // inserting the CSS at the end of what's inside <head></head>
我没有尝试,但也许(取决于班级)你可能需要将第一行变为2.
$f = $html->find('head'); $e = $f->innertext;
但是你明白了,对吗?
以上是脚本宝典为你收集整理的php – 如何使用SimpleHtmlDom在HTML标题上的头标记之间插入链接标记全部内容,希望文章能够帮你解决php – 如何使用SimpleHtmlDom在HTML标题上的头标记之间插入链接标记所遇到的问题。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。