['text' => '', 'length' => 0, 'status' => 'danger'], 'description' => ['text' => '', 'length' => 0, 'status' => 'danger'], 'h1_count' => ['count' => 0, 'status' => 'danger'], 'alt_tags' => ['missing' => 0, 'total' => 0, 'status' => 'success'], 'og_tags' => ['found' => 0, 'status' => 'warning'], ]; if (empty($html)) return $results; $doc = new DOMDocument(); @$doc->loadHTML($html); // Title $title_node = $doc->getElementsByTagName('title')->item(0); if ($title_node) { $results['title']['text'] = $title_node->nodeValue; $results['title']['length'] = strlen($title_node->nodeValue); if ($results['title']['length'] >= 10 && $results['title']['length'] <= 70) { $results['title']['status'] = 'success'; } } // Meta Description $metas = $doc->getElementsByTagName('meta'); foreach ($metas as $meta) { if (strtolower($meta->getAttribute('name')) == 'description') { $results['description']['text'] = $meta->getAttribute('content'); $results['description']['length'] = strlen($meta->getAttribute('content')); if ($results['description']['length'] >= 50 && $results['description']['length'] <= 160) { $results['description']['status'] = 'success'; } break; } if (strpos(strtolower($meta->getAttribute('property')), 'og:') === 0) { $results['og_tags']['found']++; } } if ($results['og_tags']['found'] >= 3) { // og:title, og:description, og:image $results['og_tags']['status'] = 'success'; } // H1 Count $h1s = $doc->getElementsByTagName('h1'); $results['h1_count']['count'] = $h1s->length; if ($results['h1_count']['count'] === 1) { $results['h1_count']['status'] = 'success'; } // Alt Tags $images = $doc->getElementsByTagName('img'); $results['alt_tags']['total'] = $images->length; foreach ($images as $img) { if (!$img->hasAttribute('alt') || trim($img->getAttribute('alt')) == '') { $results['alt_tags']['missing']++; } } if ($results['alt_tags']['missing'] > 0) { $results['alt_tags']['status'] = 'warning'; } return $results; } $html_input = ''; $seo_results = null; if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_POST['html_content'])) { $html_input = $_POST['html_content']; $seo_results = analyze_seo($html_input); } ?> SEO Checker - Flatlogic LAMP Demo

SEO Checker

Paste your HTML to get an on-page SEO analysis.

Analysis Results

  • Title Tag ( chars)
    0 ? 'Good' : 'Missing'; ?>
  • Meta Description ... ( chars)
    0 ? 'Good' : 'Missing'; ?>
  • H1 Tags Should be exactly one.
    found
  • Image Alt Tags All images should have descriptive alt text.
    missing / total
  • Open Graph Tags For social media sharing.
    found