Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What happens first in PHP, includes or parsing?

Assume no byte cache.

Will the my_func be parsed before a & b are included, or after?

$x=my_func();

//a.php and b.php are **very** heavy scripts
include ('a.php');
include ('b.php');


//my_func makes the browser use it's cached version of the page.
function my_func(){
  //send caching headers
  //header(....);
  exit;
}
like image 380
Itay Moav -Malimovka Avatar asked Dec 07 '25 08:12

Itay Moav -Malimovka


1 Answers

Yes, my_func will be called before the includes are executed. They're effectively a "run time" mechanism, rather than parse time. You can even include conditionally, by wrapping them in flow control.

like image 160
Adam Wright Avatar answered Dec 09 '25 20:12

Adam Wright



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!