Generally speaking, your PHP code can be sorted into two categories:
- code which does work (processing input, controller logic, database access, error handling, etc.), and
- code which produces output (
echo
,<?= $var ?>
, plain<html>
, etc.).
work goes FIRST. output goes LAST.