开发者

How to Create your own print Function PHP

开发者 https://www.devze.com 2023-01-04 05:21 出处:网络
Is there any way we can create our own print function in PHP so when using it we can do the following

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消