Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using a function before defining it in PHP

Tags:

php

in C++, all functions must be defined before using them. In PHP, can I use a function before defining it? Will it be slower?

like image 695
lovespring Avatar asked Dec 12 '22 16:12

lovespring


1 Answers

Since PHP is an interpreted language—not a compiled one—the order does not usually matter, since the contents of the script are parsed prior to the code being executed. There are a few exceptions, particularly when the existence of a function is conditional on some other code being executed.

You can read about this topic in the PHP manual here: http://www.php.net/manual/en/functions.user-defined.php

like image 74
futureal Avatar answered Feb 08 '23 03:02

futureal