['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'] = trim($title_node->nodeValue); $results['title']['length'] = strlen($results['title']['text']); if ($results['title']['length'] >= 10 && $results['title']['length'] <= 70) { $results['title']['status'] = 'success'; } } // Meta Description $metas = $doc->getElementsByTagName('meta'); foreach ($metas as $meta) { $name = strtolower($meta->getAttribute('name')); $property = strtolower($meta->getAttribute('property')); if ($name == 'description') { $results['description']['text'] = trim($meta->getAttribute('content')); $results['description']['length'] = strlen($results['description']['text']); if ($results['description']['length'] >= 50 && $results['description']['length'] <= 160) { $results['description']['status'] = 'success'; } } if (strpos($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']['total'] > 0 && $results['alt_tags']['missing'] > 0) { $results['alt_tags']['status'] = 'warning'; } return $results; } $url_input = ''; $seo_results = null; $error_message = ''; if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_POST['url'])) { $url_input = trim($_POST['url']); if (filter_var($url_input, FILTER_VALIDATE_URL)) { $context = stream_context_create([ 'http' => [ 'timeout' => 10, // 10 seconds 'user_agent' => 'FlatlogicSEOChecker/1.0', ] ]); $html = @file_get_contents($url_input, false, $context); if ($html) { $seo_results = analyze_seo($html); } else { $error_message = "Could not retrieve content from the URL. Please check if the URL is correct and publicly accessible."; } } else { $error_message = "Invalid URL provided. Please enter a valid URL (e.g., http://example.com)."; } } ?> SEO Checker - LAMP Demo

Live SEO Checker

Enter a URL to get an on-page SEO analysis.

Analysis Results for

  • Title Tag 0 ? 'OK' : 'Missing'; ?>
    ( chars)
  • Meta Description 0 ? 'OK' : 'Missing'; ?>
    ... ( chars)
  • 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