<?php $filename = '/daily.txt'; namespace dark; include_once 'phpQuery.php'; class daily { public static function getHtml() { $html = file_get_contents('link'); $document = phpQuery::newDocument($html); $echo_elements = $document->find('.informer-content'); foreach ($echo_elements as $el) { $pq = pq($el); $pq->find('.block:lt(5)')->remove(); } } getHtml(); file_put_contents($fileName, $pq); } ?> 

I get nothing at the output, although if I do not declare a class and a function, everything works.
The value of the function should display the information I need, as I understood it. If I do it without a function, then simple print $pq; it helps me, but here is a blank page without errors in the console.

  • 2
    Well, if you "declared" a class, then you need to create an instance of the same class (well, or just call a static method), then it will work. At the end write daily::getHtml() (it is better to name classes with a capital letter). And the last two lines must be removed from the class. And a little rewrite, because very porridge came out. - entithat

0