0
In Laravel it is common to work with functions like url()->to(string)
or redirect()->route(string)
where this "second function" ->to(string)
extends or returns a value to the first function url()
.
How this is done in practice in PHP?
I tried to do something similar but it didn’t 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')
Possible duplicate of What is Chaining of Methods?
– Daniel Omine