You will need to learn the basics of how PHP is displayed and other controls with it.
if (empty($counter)){ $counter = 1; }else{ echo 'plus one to $counter'; $counter++; }
Something along these lines will work for you.
PHP is pretty flexible with what you throw at it. Just remember that statements must have a semicolon at the end, and if you want to display (at the beginning), you will rely on echo statements.
Also, when working with echo operators, pay attention to the difference between single quotes and double quotes. Double quotes will process any contained variables:
$counter = 3; echo "plus one to $counter"; // output: plus one to 3 echo 'plus one to $counter'; // output: plus one to $counter
source share