当我一次做一个网站时效果很好但是当我一次做多时我得到以下错误:
警告:file_get_contents():php_network_getaddresses:getaddrinfo 失败:主机正在进行中。在 第76行的C:\ xampp \ htdocs \ blabla \ simple_html_dom.php
警告:file_get_contents(https://www.google.nl):无法打开 stream:php_network_getaddresses:getaddrinfo failed:Host is onbekend。在第76行的C:\ xampp \ htdocs \ blabla \ simple_html_dom.php
致命错误:在非对象中调用成员函数find() 第21行的C:\ xampp \ htdocs \ blabla \ backend.php
<?php
if (isset($_POST["submit"])) {
$notes = explode("\n", $_POST['linkjes']);
foreach ($notes as $link) {
x($link);
}
}
else
{
echo "je hoort hier niet";
}
function x($link){
$file = 'images.txt';
$current = file_get_contents($file);
include_once 'simple_html_dom.php';
$html = file_get_html($link);
foreach($html->find('img') as $element)
if (strpos($element->src,'.png') !== false)
{
$current .= $element->src."\n";
file_put_contents($file, $current);
}
else if (strpos($element->src,'.jpg') !== false)
{
$current .= $element->src."\n";
file_put_contents($file, $current);
}
else if (strpos($element->src,'.gif') !== false)
{
$current .= $element->src."\n";
file_put_contents($file, $current);
}
else if (strpos($element->src,'.ico') !== false)
{
$current .= $element->src."\n";
file_put_contents($file, $current);
}
else if (strpos($element->src,'.jpeg') !== false)
{
$current .= $element->src."\n";
file_put_contents($file, $current);
}
$lines = file($file);
$lines = array_unique($lines);
file_put_contents($file, implode($lines));
}
?>