Bifalgorithm post · Computer science one · Declaring Functions
Where and how can functions be defined and used in PHP?
Where and how can functions be defined and used in PHP? (Computer science one · Declaring Functions) — "In general, you can define functions anywhere in your P…
Ideas in this flowchart
- PHP function definitions can be placed flexibly within a script or codebase.
- Functions can be defined anywhere in the PHP script or codebase.
- A function may be invoked before its definition appears.
- PHP supports this placement by hoisting function definitions.
- PHP hoists definitions by processing the script in two passes.
- For good organization, function definitions should generally appear at the top of the script.
- Alternatively, function definitions can be placed in a separate PHP file.