I work with PHP Simple Dom Parser. Actually, I created a test for each tag I want to test like this:
if(count($html->find('section')) == 0){
echo '<p class="pstatus bg-danger"><span class="glyphicon glyphicon-remove"></span>Aucune balise sémantique section.</p>';
}
elseif(count($html->find('section')) >= 1){
echo '<p>Nombre de balises sémantiques section: <span>' . count($html->find('section')) . '</span></p>';
}
I try to create a function to rewrite all my code to get less lines. I tried this:
function ftest($balise,$balisetxt){
if(count($html->find('$balise')) == 0){
echo '<p class="pstatus bg-danger"><span class="glyphicon glyphicon-remove"></span>Aucune $balisetxt.</p>';
}
elseif(count($html->find('$balise')) >= 1){
echo '<p>Nombre de $balisetxt: <span>' . count($html->find('section')) . '</span></p>';
}
}
ftest('section', 'balise sémantique section');
But I got these
Notice: Undefined variable: html in E:\xampp\htdocs\testmobile\index.php on line 69
Fatal error: Call to a member function find() on a non-object in E:\xampp\htdocs\testmobile\index.php on line 69
It's like PHP can't access the $html->find thing from PHP Simple Dom Prser within a function. How should I do?