dongzhenshen7435 2011-07-25 15:48
浏览 26

PHP代码停止正常加载网站

I have this code to get the HTML source of a website/file and replace some parts of its content. Later I print the modified result

<?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(", "'", ")", "&lt;a href=&quot;", "&lt;/a&gt;", "target=&quot;_blank&quot;"); 
 $new = array("", "", "", "", "", "");
 $original = htmlspecialchars($line);
 $changed = str_replace($old, $new, $original);

?>

This code is in a file, I include this code using <?php include('newfile.php'); ?>

For some reason any other file after I include that file will not work, like <?php include('somefile.php'); ?> or <?php get_footer(); ?>

Any help will be appreciated Sorry for my English

Daniel


I got this: Notice: Undefined variable: do_not_duplicate in /usr/local/pem/vhosts/135377/webspace/httpdocs/folder/wp-content/themes/one/index.php on line 47 Warning: in_array(): Wrong datatype for second argument in /usr/local/pem/vhosts/135377/webspace/httpdocs/folder/wp-content/themes/one/index.php on line 47

The error message has nothing to do with the code provided before, the error message has someting to do with Wordpress, on line 47 is this code: <?php while (have_posts()) : the_post(); if (in_array($post->ID, $do_not_duplicate)) continue; ?><li class="contentli">


Update 1

Error message says:

Parse error: syntax error, unexpected $end in /usr/local/pem/vhosts/135377/webspace/.../newfile.php(26) : eval()'d code on line 1

Parse error: syntax error, unexpected $end in /usr/local/pem/vhosts/135377/webspace/.../newfile.php(30) : eval()'d code on line 1

Fatal error: Cannot break/continue 1 level in /usr/local/pem/vhosts/135377/webspace/.../newfile.php on line 32


Update 2

There is no error message but the content of the footer (<?php get_footer(); ?>) is on the source code of the site but not visible to users. (If I check the source code of the site i can find all the elements of the footer file, but these elements aren't properly rendered on the browser)

  • 写回答

3条回答 默认 最新

  • doushi3715 2011-07-25 15:53
    关注

    Your not doing anything in you're loop... perhaps code should be:

    <?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) {
        $old = array("document.write(", "'", ")", "&lt;a href=&quot;", "&lt;/a&gt;", "target=&quot;_blank&quot;"); 
        $new = array("", "", "", "", "", "");
        $original = htmlspecialchars($line);
        $changed = str_replace($old, $new, $original);
    
    } 
    ?>
    
    评论

报告相同问题?

悬赏问题

  • ¥15 R语言Rstudio突然无法启动
  • ¥15 关于#matlab#的问题:提取2个图像的变量作为另外一个图像像元的移动量,计算新的位置创建新的图像并提取第二个图像的变量到新的图像
  • ¥15 改算法,照着压缩包里边,参考其他代码封装的格式 写到main函数里
  • ¥15 用windows做服务的同志有吗
  • ¥60 求一个简单的网页(标签-安全|关键词-上传)
  • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值