Variable functions

Variable functions won' t work with language constructs such as echo( ) , unset( ) , isset( ) , empty( ) and include( ) . Although , the construct print( ) is an exception and will work . This is one of the major differences between PHP functions and language constructs .

דוגמה 12-1 .

 
?php

 
function

 
foo(

 
)

 
{

 
echo

 
"In

 
foo(

 
)

 
br

 
\n"

 
;

 
}

 
function

 
bar($arg

 
=

 
''

 
)

 
{

 
echo

 
"In

 
bar()

 
;

 
argument

 
was

 
'$arg'

 
.

 
br

 
\n"

 
;

 
}

 
$func

 
=

 
'foo'

 
;

 
$func()

 
;

 
$func

 
=

 
'bar'

 
;

 
$func('test')

 
;

 
?





See also variable variables and function_exists( ) .