1
<?php
require_once 'simple_html_dom.php';
class temperatura {
public function __construct(){
$this->getTemperatura('https://www.tempoagora.com.br/previsao-do-tempo/pe/Petrolina/');
}
public function getTemperatura($url){
$html = file_get_html($url);
echo'<pre>';
print_r($html);
}
}
$t = new Temperatura();
?>
How to allow PHP to return without this memory problem?
already made changes in php.ini?
– Jonathan de Toni
Yes, In the address lines: C: xampp php.ini memory_limit=128M for 256M ;opcache.memory_consumption=128 for 512
– Sergio Bentes
I think you should think about using the weather API to do this. However, do a test: Instead of using
print_r($html);
useecho $html->plaintext;
and see if the error continues.– Andrei Coelho
The Error did not continue, I got the following return: "Petrolina weather forecast - PE - Weather Now Click on a day to see the weather forecast per hourTemp.Rainfall" In case I expected the return of an array, but all right, error solved. Thank you.
– Sergio Bentes
Ah ta... calm and I’ll create an answer.
– Andrei Coelho
I was going to create an answer... but I think it’s not convenient. I’ll show you right here:
– Andrei Coelho
According to the documentation, to get the object array, use:
$html->getAllAttributes ()
; http://simplehtmldom.sourceforge.net/manual_api.htm– Andrei Coelho
It is interesting to send a reply to close the post
– Sergio Bentes
I’ll formulate, calm down and...
– Andrei Coelho