I am using the PHP lib Simple HTML Dom Parser, as suggested here ( How do you parse and process HTML/XML in PHP? ) to parse a webpage's html content.
To create the DOM, I have to do:
$html = file_get_html('http://www.example.com/');
The problem is that if I do:
$html = file_get_html('www.example.com');
without specifying the URL's protocol, I will get an error.
My question is: How can I get to know if the URL with the protocol is "http://www.example.com/" or "https://www.example.com/" having in hands only the string "www.example.com"?