Strpos总是给出真实的

I have two type of links which are strings taken from database:

http://www.website.com/anything-else.html
www.website.com/anything-else.html

I need ALL links to be displayed with http:// no matter what so Im using this simple code to determine whether link has http in it and if not add it:

if (strpos($links, 'http') !== true) {
    $linkai = 'http://'.$links;
}

The problem is, it is adding http:// to any link no matter if it has it or not. I tried ==false ect. Nothing works. Any ideas?

Try this

if (strpos($links, 'http') === false) {
   $linkai = 'http://'.$links;
}

In strpos documentation says return value not Boolean always.

"Warning This function may return Boolean FALSE, but may also return a non-Boolean value which evaluates to FALSE. Please read the section on Booleans for more information. Use the === operator for testing the return value of this function."

$arrParsedUrl = parse_url($links);
            if (!empty($arrParsedUrl['scheme']))
            {
                // Contains http:// schema
                if ($arrParsedUrl['scheme'] === "http")
                {

                }
                // Contains https:// schema
                else if ($arrParsedUrl['scheme'] === "https")
                {

                }
            }
            // Don't contains http:// or https://
            else
            {
                $links = 'http://'.$links;
            }
            echo $links;