How to Create your own print Function PHP
Is there any way we can create our own print function in PHP so when using it we can do the following
my_print_function "My Content";
rather than
my_print_function("My Content开发者_StackOverflow");
No, there is not. The ones without brackets (like echo, and include) are language constructs, which you can't make in your own code. Could probably do it by making a PHP extension in C, but it's not possible in pure PHP.
No, PHP syntax requires parenthesis for custom functions. print
, echo
etc. are language constructs, meaning they're special cases hardcoded into the PHP engine. You'll have to extend the core PHP engine if you want to create something similar.
精彩评论