Reputation: 534
Is it possible to define a function and use without ()?
Like require("a.php")
and require "a.php"
.
function getNameById($id){}; /*and use it like*/ $id = getNameById "1";
Thanks.
Upvotes: 0
Views: 103
Reputation: 9491
As other have mention, require
and for example echo
, isset
and empty
are language constructs. Which means that it is built into the php core.
The only way you can create your own constructs is by writing a php extension in C. So to answer your question, not in pure php.
Upvotes: 1
Reputation: 12806
require
is a special language construct, not a function, and no, it's not possible.
Upvotes: 2
Reputation: 225054
No, that's not possible. require
is a language construct; not a function.
Upvotes: 3
Reputation: 222288
No, it isn't. require
is a language construct, just like echo
, print
, include
, etc.
Upvotes: 8