Mod Removes Wiki by Doorknob
2 Added expected output comment
source | link

Running functions inside strings.

Try this:

$a='strlen';
echo "This text has {$a('15')} chars";

Or try this:

//only php>=5.3
$if=function($c,$t,$f){return$c?$t:$f;};
echo <<<HEREDOCS
    Heredocs can{$if(true,' be','not be')} used too and can{$if(<<<BE
{$if(true,1,0)}
BE
,'','not')} be nested
HEREDOCS;
//Expected output: Heredocs can be used too and can be nested

This only works with strings using "" and heredocs (DON'T make confusion with nowdocs).

Using nested functions is only possible inside nested heredocs (or you will run into parse errors)!

Running functions inside strings.

Try this:

$a='strlen';
echo "This text has {$a('15')} chars";

Or try this:

//only php>=5.3
$if=function($c,$t,$f){return$c?$t:$f;};
echo <<<HEREDOCS
    Heredocs can{$if(true,' be','not be')} used too and can{$if(<<<BE
{$if(true,1,0)}
BE
,'','not')} be nested
HEREDOCS;

This only works with strings using "" and heredocs.

Using nested functions is only possible inside nested heredocs (or you will run into parse errors)!

Running functions inside strings.

Try this:

$a='strlen';
echo "This text has {$a('15')} chars";

Or try this:

//only php>=5.3
$if=function($c,$t,$f){return$c?$t:$f;};
echo <<<HEREDOCS
    Heredocs can{$if(true,' be','not be')} used too and can{$if(<<<BE
{$if(true,1,0)}
BE
,'','not')} be nested
HEREDOCS;
//Expected output: Heredocs can be used too and can be nested

This only works with strings using "" and heredocs (DON'T make confusion with nowdocs).

Using nested functions is only possible inside nested heredocs (or you will run into parse errors)!

1
source | link

Running functions inside strings.

Try this:

$a='strlen';
echo "This text has {$a('15')} chars";

Or try this:

//only php>=5.3
$if=function($c,$t,$f){return$c?$t:$f;};
echo <<<HEREDOCS
    Heredocs can{$if(true,' be','not be')} used too and can{$if(<<<BE
{$if(true,1,0)}
BE
,'','not')} be nested
HEREDOCS;

This only works with strings using "" and heredocs.

Using nested functions is only possible inside nested heredocs (or you will run into parse errors)!