In laravel framework i often use - Model::find($id)->orderedBy(param);
I would like to know how to achieve such expression. I began with this:
Class Test
{
static public function write()
{
echo "text no 1";
function second()
{
echo "text no 2";
}
}
}
now i when i do
Test::write();
i get "text no 1"
what i want is to do:
Test::write()->second();
and get " text no 2"
Unfortunately my way doesn't work.
Is it possible ?
Excuse me for bad language - still learning.
write
) mustreturn $this
(or some other object, less commonly). Sincewrite
isstatic
and does not have a$this
, it should somehow produce an object and return that (this is whatfind
has to do in the Laravel example). – Jon Jun 16 '13 at 19:55second()
isn't part of the class, but is registered in the global scope; and subsequent calls to write() will complain that it is already defined – Mark Baker Jun 16 '13 at 20:07