tags:

views:

86

answers:

3

Hey all,

I was wondering if there is any nice way of writing functions in PHP so that they don't require ( ) around the parameters.

Example:

function sayThis($str) {
    echo $str;
}

sayThis "hi!!";

Thanks, Matt Mueller

+1  A: 

Simple answer, no.

echo is a language construct not a function, hence it doesn't need the parentheses.

Alix Axel
+6  A: 

There just isn't. "echo" is more an operator than a function, so you'd actually need to rewrite some php source in order to introduce new "functions" like those.

Edit: Actually, there more accurate term for "echo" is, as eyze has correctly pointed out, language construct rather than operator. http://php.net/manual/de/function.echo.php provides some more information.

x3ro
Interesting! Thanks.
Matt
+1  A: 

see this answer

Marek Karbarz