Mecha CMS

URL::long()

Convert relative URL into full URL.

2.0.0 Static

URL::long(string $value, bool $ground = true);
URL::long(string $value, bool $ground = true, URL $url = $GLOBALS['url']);
URL::long(string $value, string $root);

Example:

$A = URL::long("");
$B = URL::long('foo');
$C = URL::long('?foo');
$D = URL::long('&foo');
$E = URL::long('#foo');
$F = URL::long('javascript:;');
$G = URL::long('data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7');
$H = URL::long('foo/bar');
$I = URL::long('?foo&bar');
$J = URL::long('&foo&bar');
$K = URL::long('//foo');
$L = URL::long('http://foo');
$M = URL::long('/');
$N = URL::long('/foo');
$O = URL::long('/?foo');
$P = URL::long('/&foo');
$Q = URL::long('/#foo');
$R = URL::long('/javascript:;');
$S = URL::long('/foo/bar');
$T = URL::long('/?foo&bar');
$U = URL::long('/&foo&bar');

Result:

$A = 'https://mecha-cms.com/reference/class/u-r-l/long';
$B = 'https://mecha-cms.com/reference/class/u-r-l/foo';
$C = 'https://mecha-cms.com/reference/class/u-r-l/long?foo';
$D = 'https://mecha-cms.com/reference/class/u-r-l/long?foo';
$E = 'https://mecha-cms.com/reference/class/u-r-l/long#foo';
$F = 'javascript:;';
$G = 'data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7';
$H = 'https://mecha-cms.com/reference/class/u-r-l/foo/bar';
$I = 'https://mecha-cms.com/reference/class/u-r-l/long?foo&bar';
$J = 'https://mecha-cms.com/reference/class/u-r-l/long?foo&bar';
$K = 'https://foo';
$L = 'http://foo';
$M = 'https://mecha-cms.com';
$N = 'https://mecha-cms.com/foo';
$O = 'https://mecha-cms.com?foo';
$P = 'https://mecha-cms.com?foo';
$Q = 'https://mecha-cms.com#foo';
$R = 'https://mecha-cms.com/javascript:;';
$S = 'https://mecha-cms.com/foo/bar';
$T = 'https://mecha-cms.com?foo&bar';
$U = 'https://mecha-cms.com?foo&bar';

Note: If $ground is false, then the result will always relative to the URL path where the CMS is being installed. The $ground parameter changes makes sense only when Mecha is installed in a sub-directory.

0 Comments

No comments yet.