Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does PHP parse functions

Well I confused by behavior of PHP when parsing a PHP file. I am reading this since long that

The PHP language is interpreted

So I have code

var_dump(function_exists('abc')); exit;
function abc() {
    return;
}

var_dump should print false as per my assumption but it print bool(true).

Can somebody please help me to understand this behavior?

like image 623
Sumit Avatar asked Jan 01 '26 02:01

Sumit


1 Answers

See this answer.

In short, it is compiled into a type of bytecode at runtime and then interpreted - in doing this, you will have the definitions for your functions available, even if they appear at the very end.

like image 109
Matt Clark Avatar answered Jan 02 '26 15:01

Matt Clark



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!