Increment/decrement
  1. Create a new script with this code:

    <?php

    $cars_on_lot = 10;

    print "We have $cars_on_lot cars.\n
    ";

    print "We got another new car.\n
    ";

    $cars_on_lot++;

    print "Now we have $cars_on_lot cars!\n<p>";

    print '<b>$cars_on_lot++</b> is the same to PHP as <b>$cars_on_lot + 1.</b>';

    ?>
  2. Save the script as autoplus.php in the PHPSCRIPTS folder.

    Here's what the relevant lines in this script do:
  • $cars_on_lot++;

    The auto incrementer (++) adds 1 to the $cars_on lot variable.

  • print '<b>$cars_on_lot++</b> is the same to PHP as <b>$cars_on_lot = $cars_on_lot + 1</b>';

    Prints the literal text: $cars_on_lot++ is the same to PHP as $cars_on_lot + 1.