In Laravel it is common to work with functions such as url()->to(string)
or redirect()->route(string)
where this "second function" ->to(string)
extends or returns a value for the first function url()
.
How is this done in practice in PHP?
I tried to do something similar but it did not work:
function to($path)
{
return $path;
}
/**
* Return the base theme url.
*
* @return string
*/
function url(string $path = null)
{
if(isset($path))
$path = "/{$path}";
return get_template_directory_uri() . $path;
}
Execution:
url()->to('teste')