Since many PHP-related questions are very basic here, I'd propose to prepare a collection of tips and tricks.
This might be a starting point:
- Check as much input parameters of as much methods as possible (see assert()).
- Log all errors to a log-file and visualize it using your admin backend (see set_error_handler()).
- Use type-hints as often as possible (see type-hinting)
- Set the error level to the absolute maximum. Then code in such a way, that not a single warning appears (see error_reporting()).
- Learn why and how PHP implements and converts data types (see type juggling and string conversions)
Thus the question is: What should PHP newbies better do?
UPDATE-1
Since quite some people reviewed this question, I'd propose to reopen it. Please click on the respective link below.
Test
You should better test your code, probably practicing TDD. You can do this thanks to PHPUnit. Keep in mind Uncle Bob's three rules to practice TDD.
You should try to have high code coverage. PHPUnit can also do code coverage analyses thanks to xdebug. Refactoring code that is smelly(list) should be easy, because of your test-cases which are already present.
Security
Performance
echo
,print_r
). Invaluable.