Skip to content

get_url ​

php
string get_url(string $url , [number $extra ], [string $encoding])

Retrieves content (for example a web page) from the URL supplied as the first argument. The optional second argument enables additional processing of the retrieved content. $extra is a bitmask with the following values: 1 - convert the content to the system's internal encoding (UTF-8). The content is converted as it is retrieved. For a web page, the function tries to determine the encoding from its <meta> tag. If this is not possible, supply the encoding in the third argument, $encoding. This option should always be enabled! 2 - repair HTML. The system tries to repair the retrieved HTML document to meet SARE's newsletter requirements. This option should always be enabled for HTML documents (web pages). It may be disabled for other documents because it modifies the content. 4 - attempt to convert relative links to absolute links. When retrieving a web page, the function tries to convert relative image and page links to absolute URLs so the page displays correctly when sent as a newsletter. If the second argument is omitted, it defaults to 7 (1 + 2 + 4), enabling all three options.

Returns the retrieved content, or false on failure.

NOTE: This function does not work in an email address context (where an email address is required; see Appendix B). It returns false in that context.

Example:

php
$txt = 'Click to view the newsletter %www_version%';
$html = get_url('<span style="text-decoration: underline;"><a href="../../../../../../">http://www.sare.pl/'</a></span>);

if ($html !== false) {
  newsletter_create($txt, $html, 'Newsletter '.date("Y-m-d"), 'Pobrano ze strony www.sare.pl');
}