PHP脚本打破HTML文档的其余部分[关闭]

问题描述 投票:-1回答:1

编辑:已解决 - 感谢@Adam的评论

我有我的index.php页面,所有包含的功能,直到现在,已经工作。我编写了一个小脚本(粘贴在下面),使用Simple HTML DOM库来抓取外部网页以获取元素值。该值在脚本中存储为$ newprice。但是,当我将脚本放在代码中的任何位置时,它a)不运行,并且b)中断它之前的所有HTML / PHP / JS代码。

<?php
  include_once('../simple_html_dom.php');
  $html = file_get_html('https://www.affordrentacar.co.uk/');
  $traverse = $html->find('span.offer-price', 0);
  $newprice = $traverse->plaintext;
?>

我已经将这个脚本复制到我的其他一个PHP页面并进行了测试,回显了$ newprice变量,并且运行正常。可能是什么导致了这个?

php html simple-html-dom
1个回答
2
投票

尝试显示错误:

error_reporting( E_ALL^E_NOTICE );
ini_set('display_errors', 1);

可能是连接问题,您的本地设置不适用于https

© www.soinside.com 2019 - 2024. All rights reserved.