Skip to content

Instantly share code, notes, and snippets.

@itskingori
Created December 20, 2013 06:52
Show Gist options
  • Save itskingori/8051286 to your computer and use it in GitHub Desktop.
Save itskingori/8051286 to your computer and use it in GitHub Desktop.
Assigning Variables and Using Operators
<!DOCTYPE html>
<html>
<head>
<title>Exercise 03: Assigning Variables and Using Operators</title>
</head>
<body>
<?php
// Write a script to reproduce the output below
// Value is now 8.
// Add 2. Value is now 10.
// Subtract 4. Value is now 6.
// Multiply by 5. Value is now 30.
// Divide by 3. Value is now 10.
// Increment one. Value is now 11.
// Decrement one. Value is now 10.
// Assign 8 to $value
$value = 8;
echo "Value is now ".$value.".<br/>";
// Add 2 to $value
$value = $value + 2;
echo "Add 2. Value is now ".$value.".<br/>";
// Add 2 to $value
$value = $value - 4;
echo "Subtract 4. Value is now ".$value.".<br/>";
// Multiply $value by 5
$value = $value * 5;
echo "Multiply by 5. Value is now ".$value.".<br/>";
// Divide $value by 3
$value = $value / 3;
echo "Divide by 3. Value is now ".$value.".<br/>";
// Increment $value by one
$value++;
echo "Increment one. Value is now ".$value.".<br/>";
// Decrement $value by one
$value--;
echo "Decrement one. Value is now ".$value.".<br/>";
?>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment