我有这段代码来获取网站/文件的 HTML 源代码并替换其内容的某些部分。后来我打印修改后的结果
<?php
// Get a file into an array. In this example we'll go through HTTP to get
// the HTML source of a URL.
$lines = file($link);
// Loop through our array, show HTML source as HTML source; and line numbers too.
foreach ($lines as $line_num => $line) {
}
?>
<?php
$old = array("document.write(", "'", ")", "<a href="", "</a>", "target="_blank"");
$new = array("", "", "", "", "", "");
$original = htmlspecialchars($line);
$changed = str_replace($old, $new, $original);
?>
此代码在一个文件中,我使用包含此代码<?php include('newfile.php'); ?>
由于某种原因,我包含该文件后的任何其他文件都将不起作用,例如<?php include('somefile.php'); ?>
或<?php get_footer(); ?>
任何帮助将不胜感激对不起我的英语
丹尼尔
我得到了这个:注意:未定义的变量:第 47 行 /usr/local/pem/vhosts/135377/webspace/httpdocs/folder/wp-content/themes/one/index.php 中的 do_not_duplicate 警告:in_array():错误的数据类型对于第 47 行 /usr/local/pem/vhosts/135377/webspace/httpdocs/folder/wp-content/themes/one/index.php 中的第二个参数
错误信息与之前提供的代码无关,错误信息与Wordpress有关,第47行是这样的代码:<?php while (have_posts()) : the_post(); if (in_array($post->ID, $do_not_duplicate)) continue; ?><li class="contentli">
更新 1
错误信息说:
解析错误:语法错误,/usr/local/pem/vhosts/135377/webspace/.../newfile.php(26) 中的意外 $end :第 1 行的 eval() 代码
解析错误:语法错误,/usr/local/pem/vhosts/135377/webspace/.../newfile.php(30) 中的意外 $end :第 1 行的 eval() 代码
致命错误:无法在第 32 行的 /usr/local/pem/vhosts/135377/webspace/.../newfile.php 中中断/继续 1 级
更新 2
没有错误消息,但页脚 ( <?php get_footer(); ?>
) 的内容在网站的源代码上,但用户看不到。(如果我检查网站的源代码,我可以找到页脚文件的所有元素,但这些元素没有在浏览器上正确呈现)