Vahan
Vahan

Reputation: 534

Define php function and use without ()

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

Answers (4)

Mattias
Mattias

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

Michael
Michael

Reputation: 12806

require is a special language construct, not a function, and no, it's not possible.

Upvotes: 2

Ry-
Ry-

Reputation: 225054

No, that's not possible. require is a language construct; not a function.

Upvotes: 3

Dogbert
Dogbert

Reputation: 222288

No, it isn't. require is a language construct, just like echo, print, include, etc.

Upvotes: 8

Related Questions