what's last argument in Phalcon\Mvc\Url::get() for?

What is the goal of the last $local argument in Phalcon\Mvc\Url::get()?

public string get ([string|array $uri], [unknown $args], [bool|null $local])

It is not explained in the docs. I have tried to generarte URL with this argument set to true and false but haven't found any difference.

edited Aug '14

I think this argument is true by default, this is to indicate if the url is local (relative) or external (absolute)

$URL = new Phalcon\Mvc\Url;
// If you are on http://example.com/XX/
echo $URL->get('google.com', array(), false); //   CC/AA .. local relative to the current URL, http://example.com/XX/google.com
echo $URL->get('google.com', array(), true); //   /CC/AA .. local absolute to the current Domain, http://example.com/google.com
// Adding HTTP://
echo $URL->get('http://google.com', array(), false); //  external absolute URL, http://google.com
echo $URL->get('http://google.com', array(), true); //   local relative to the current URL http://example.com/XX/CC/AA/http://google.com
// So from the results you can see which links is true or not


@hishamaborob could you explain it a little more? I don't get it yet. What you mean by "work"?

Why sb would produce a link like "google.com" with URL component?

I have tried to generate some URLs with this 3rd parameter set to true and false and there is no difference in what is produced.

Sorry there was some mistakes, I fixed it and made it more clear I hope


Last line of your code is:

echo $URL->get('http://google.com', array(), true); // http://example.com/XX/CC/AA/http://google.com

How the URL component is capable to add these letters CC/AA between http://example.com/XX and http://google.com? Where the string CC/AA is defined?


I have tried your code. I have changed all echo to var_dump:

$URL = new \Phalcon\Mvc\Url;
var_dump($URL->get('google.com', array(), false));
var_dump($URL->get('google.com', array(), true));
var_dump($URL->get('http://google.com', array(), false));
var_dump($URL->get('http://google.com', array(), true));

What I have received is:

string 'google.com' (length=10)
string '/public/google.com' (length=18)
string 'http://google.com' (length=17)
string '/public/http://google.com' (length=25)