The error related settings should go in the php.ini, so that they can be changed at a single point, they will cause php syntax errors to be reported, and you don’t need to remember to put them into code for debugging and remove or change them when moving code to a live server. The php.ini should have existing lines setting these, but you may need to change the actual values to those shown. You should also set php’s output_buffering to OFF.
Php’s functions use the ‘black box’ model (which you can break if you are into bad coding that’s hard to debug when a variable gets mixed up and changed by some code elsewhere), where the only affect a function call has on the calling code can be seen/tested at the point of the function call. This allows the code inside of functions to do whatever they need to do without needing to keep track of anything going on outside of the function code. This makes writing larger applications, and when multiple programmers are working on a project, easier, since you don’t need to keep track of and insure all the variables being used or modified inside of functions are unique.
The black box model works by accepting all inputs as call-time parameters (the way you have theorized above), performing whatever processing the function has been designed to do, then returning the result to the calling code.
Some notes about functions. A function should be responsible for doing one thing, that helps you to build an application, by simplifying the main logic and eliminating repetitive logic, i.e. they are helpful building blocks. Functions should be general purpose, reusable. They should not contain application specific values that change when moved to a different server or a different domain. Functions should not echo output. You should not find yourself regularly editing the code inside of a function or copying/changing the code with a different function name. If the code inside of a function is just part of your main program logic, surrounded by a function definition, all you have done is add a layer of unnecessary syntax.