SEO

PHP Backlink Checker Script: What It Can Do and a Safer Alternative

A PHP script cannot discover backlinks on its own. Here is what a script can check, a working PHP link verifier, and where the real link data comes from.

By Zoqonyx Team · November 25, 2026 · 2 min read

Two software developers at their desks in a bright office

A PHP backlink checker script sounds simple: give it a domain, get a list of backlinks. In practice, a script cannot find backlinks by itself. Backlinks live on other people's websites, so finding them needs a crawler that has already visited billions of pages. That is what providers like Ahrefs, Moz and Majestic maintain. A script you write can do something different and still useful: check whether links you already know about are still there.

What a script can and can't do

  • Can: fetch a page, check that it loads normally, and look for a link to your domain. Report the anchor text and the rel attribute (follow, nofollow, sponsored, ugc).
  • Can't: discover new backlinks across the web. For that you need a backlink index, either from an API (see the options) or from the free Links report in Google Search Console.

This function takes a page that should link to you and checks it. It needs PHP 8 with the cURL and DOM extensions.

<?php
function checkLink(string $pageUrl, string $targetHost): array {
    $ch = curl_init($pageUrl);
    curl_setopt_array($ch, [
        CURLOPT_RETURNTRANSFER => true,
        CURLOPT_FOLLOWLOCATION => true,
        CURLOPT_TIMEOUT => 15,
        CURLOPT_USERAGENT => 'MyLinkCheck/1.0 (+https://example.com/about-this-bot)',
    ]);
    $html = curl_exec($ch);
    $status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
    curl_close($ch);

    if ($html === false || $status >= 400) {
        return ['found' => false, 'status' => $status];
    }

    $dom = new DOMDocument();
    @$dom->loadHTML($html);
    foreach ($dom->getElementsByTagName('a') as $a) {
        $host = parse_url($a->getAttribute('href'), PHP_URL_HOST);
        if ($host && str_ends_with($host, $targetHost)) {
            return [
                'found'  => true,
                'status' => $status,
                'rel'    => $a->getAttribute('rel'),
                'anchor' => trim($a->textContent),
            ];
        }
    }
    return ['found' => false, 'status' => $status];
}

Loop over your list of known linking pages, call the function for each one, and write the results to a CSV file.

Rules for running it

  1. Be polite. Add a delay between requests and name your bot in the user agent.
  2. Respect robots.txt, and don't send many requests to one site.
  3. Run it on a schedule, such as weekly, and keep dated results so you can see links appear and disappear.
  4. Don't scrape search engine result pages. It breaks their terms and gets your server blocked.

Where to get the list of linking pages

Export it from Search Console: open Links, then Top linking sites or Latest links. Then drop the file into the Zoqonyx backlink checker to count referring domains, see the most common anchor texts and flag risky links. The file is read in your browser and is not uploaded.

Need something built?

If you want a link monitor inside your own dashboard, our team builds this kind of tool. See custom software development or contact us.

Written by Zoqonyx Team. Last updated November 25, 2026.

Need help with this?

Tell us what you are working on and we will reply with suggestions and next steps.

  • hello@zoqonyx.com
  • Tell us about your idea and we will reply with questions. We work remotely with clients in the USA, Europe, the Gulf and Asia.

Or email us at hello@zoqonyx.com