Recently I found out about with
and let
statements for javascript.
I'm interested in achieving something like mentioned here: https://stackoverflow.com/a/1462102/393406, except for PHP in OOP fashion.
Like:
$builder = new markupbuilder();
with($markupbuilder){
div(
h1('A title...') .
p('This is ' . span('paragraph') . ' here.')
);
}
// respectively
$builder->div(
$builder->h1('A title...') .
$builder->p('This is' . $builder->span('paragraph') . ' here')
);
So, is there something similar for PHP or how could I achieve this in PHP?