Sarfraz
Sarfraz

Reputation: 382756

Can we replace PHP language constructs with our own?

PHP allows you to replace or even re-name PHP's built-in functions using functions such as override_function and rename_function.

Can we override the PHP's language constructs like echo and eval?

Upvotes: 4

Views: 917

Answers (2)

Dave Challis
Dave Challis

Reputation: 3906

No, this isn't possible within PHP.

The only way I can think of would be to create a custom handler for PHP files (in apache or whichever web server you're using).

The custom handler could then search and replace core language constructs with functions of your own, before being passed to the real PHP handler.

Upvotes: 3

Pascal MARTIN
Pascal MARTIN

Reputation: 401032

I don't think it's possible : it's a language construct, which means something that's more than "integrated" to the language : it's really a "part" of the language.

Upvotes: 5

Related Questions