I
I
Ilya2018-05-05 01:42:59
PHP
Ilya, 2018-05-05 01:42:59

Why doesn't the first example from the PHP HTML Parser documentation work?

I installed PHP HTML Parser via Composer, I'm doing the first example from the documentation - nothing is displayed.

require 'vendor/autoload.php';
use PHPHtmlParser\Dom;

$dom = new Dom;
$dom->load('<div class="all"><p>Hey bro, <a href="google.com">click here</a><br /> :)</p></div>');
$a = $dom->find('a')[0];
echo $a->text; // click here

By the way, why refer to vendor/autoload.php in the beginning ?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
spaceatmoon, 2018-05-05
@sidorchik

I do not recommend using this library. I didn’t find any documentation except on the main page of the project or didn’t look for it well. Therefore, you can only guess about its capabilities. I read that there is a lib inside and she doesn’t know how to search by attributes, which, in principle, is not described in the docks.
I personally tried to use this library. As a result, I spat and went back to Simple HTML DOM
simplehtmldom.sourceforge.net
For 4 years now, the library has not been updated, but supports all perverted content search methods.
Simple as a stick and excellent documentation. For PHP this is probably a must have.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question