A few common PHP mistakes:
- Using require_once when a simple require would achieve the same result. Using require uses less system resources and therefore executes more quickly. You should engineer your code so you don’t need to use require_once. The same of course applies to include statements.
- Failing to declare variables before attempting to use them.
- Don’t use absolute paths and URLs where relative will suffice
- Not opening code for peer review. Often others will have ingenuous just like you about how to optimise your code. Make use of the resources you have.
- Using double quotes where an apostrophe will fit better. Only use “ where the string you are constructing contains ‘ or variables you wish to substituted. This saves the PHP parser from expanding text it doesn’t need to.
- It is recommended that you place the value you wish to match before the variable you hope to find it in. Eg. if (‘test’ == $var) { } This prevents the value being assigned to the variable should you forget an =