Home >Backend Development >PHP Tutorial >PHP article collection URL completion function (FormatUrl)_PHP tutorial
Write a function that is necessary for collection, the URL completion function, which can also be called FormatUrl.
The purpose of writing this function is to develop a collection program. When collecting articles, you will often encounter that the path in the page is "relative path" or "absolute root path" and is not "absolute full path", so the URL cannot be collected.
Therefore, this function is needed to format the code and format all hyperlinks, so that the correct URL can be collected directly.
Popularization of path knowledge
Relative path: "../" "./" or add nothing in front
Absolute root path: /path/xxx.html
Absolute full path: http://www.xxx.com/path/xxx.html
Usage example: