简体   繁体   中英

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?

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.

function_exist will Checks the list of defined functions, both built-in (internal) and user-defined, for function_name. So, php interpreter checks if the function with the name is defined in the bytecode which is complied before interpreted.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM