why don't we write parenthesis inside of an echo function in PHP? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

why don't we write parenthesis inside of an echo function in PHP?

Php

12th Mar 2019, 7:58 AM
Arun Kunj
Arun Kunj - avatar
2 Answers
+ 3
since echo is not a function, we do not use parenthesis when calling it. example: echo "hello"; as opposed to echo ("hello"); If it were to be a function, it would have been forced to be called as echo ("hello"); In ASP/Vbscript, I can call a function one of the following ways; call dosomething("x","y","z") dosomething "x","y","z" notice the missing parathesis The closest thing I have seen to this parenthesis-free syntax in PHP is the echo. I like the ability to skip the parenthesis. My question to you is if there is a way to write a function in PHP, that would not require the use of the parenthesis?
12th Mar 2019, 8:39 AM
Troy🌹
Troy🌹 - avatar
0
Arun Kunj can you give an example, please?
12th Mar 2019, 8:37 AM
Ulisses Cruz
Ulisses Cruz - avatar