Have seen lots of individual threads on how to generate a fully qualified website URL, e.g.
https://www.example.com/
The majority of the threads are a few years old and have mentions of security risks with using the code.
Is there a more up to date and secure way of retrieving the qualified URL in PHP?
UPDATE:
I wish to keep a global string, auto-generated, of the top level website address to use in the pages on the website.