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.
Feed/

Where and how can functions be defined and used in PHP?

No cover

Channel

Computer science one

1 page

"In general, you can define functions anywhere in your PHP script or codebase. They can even appear after code that invokes them because PHP hoists the function definitions by doing two passes of the script. However, it is good style to include function definitions at the top of your script or in a separate PHP file for organization."

Flowchart preview
👍
0
0 comments0 shares

Sign in to view and post comments.