PHP PHP Basics Unit Converter Manipulating Numbers

Robert Skaggs
Robert Skaggs
917 Points

Hi How should I add 1 to an integer that has already been defined as a variable in PHP? Thanks,

Hi How should I add 1 to an integer that has already been defined as a variable in PHP? should I be using a certain function in PHP?

index.php
<?php

//Place your code below this comment

$integerOne=1;
$integerTwo=2;
$floatOne=1.5;



?>

1 Answer

Joseph Yhu
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Joseph Yhu
PHP Development Techdegree Graduate 46,902 Points

Like this: $integer = $integer + 1, or simpler $integer += 1, even simpler (only works if you are adding 1 or subtracting 1) $integer++ or ++$integer.