Tuesday, March 14, 2017

Why is my domdocument code not working?

I'm trying to do some error handling but it doesn't work.

foreach ($meta as $node) {
        if($node->getAttribute('name')=='description' && $node->getAttribute('content') > 0) {
            $ts->description = $node->getAttribute('content');
        }
        else {
            $ts->description = 'No description found';
        }
    }

This doesn't work.. It cannot find the right meta tag. Instead of finding the meta tag for description it finds <meta name="viewport" content="width=device-width,initial-scale=1">

Declaration $ts:

$ts = new Scan;

$ts->save();

It's for saving it to the database in Laravel.



via itvba

Advertisement