Creating functions without parentheses in PHP like 'echo'

前端 未结 2 1138
忘掉有多难
忘掉有多难 2021-01-05 06:50

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         


        
相关标签:
2条回答
  • 2021-01-05 07:13

    There simply isn't. "echo" is more of an operator than a function, so you'd actually need to rewrite the PHP interpreter source in order to introduce new "functions" like those.

    Edit: Actually, the 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.

    0 讨论(0)
  • 2021-01-05 07:17

    Simple answer, no.

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

    0 讨论(0)
提交回复
热议问题