frame

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In Register

PHP Operators 5

PHP Operators

Comparison operator: Less than or equal (<=)

<!DOCTYPE html>
<html>
<body>


<?php
$x = 50;
$y = 50;


var_dump($x <= $y); // returns true because $x is less than or equal to $y
?>  


</body>
</html>


Comparison operator: Spaceship (<=>)

<!DOCTYPE html>
<html>
<body>


<?php
$x = 5;  
$y = 10;


echo ($x <=> $y); // returns -1 because $x is less than $y
echo "<br>";


$x = 10;  
$y = 10;


echo ($x <=> $y); // returns 0 because values are equal
echo "<br>";


$x = 15;  
$y = 10;


echo ($x <=> $y); // returns +1 because $x is greater than $y
?>  


</body>
</html>


Increment operator: ++$x

<!DOCTYPE html>
<html>
<body>


<?php
$x = 10;  
echo ++$x;
?>  


</body>
</html>


Increment operator: $x++

<!DOCTYPE html>
<html>
<body>


<?php
$x = 10;  
echo $x++;
?>  


</body>
</html>

Decrement operator: --$x

<!DOCTYPE html>
<html>
<body>


<?php
$x = 10;  
echo --$x;
?>  


</body>
</html>


Tagged:
Sign In or Register to comment.

Developer

| make vanilla clean and light
@ 2016 Your Sitename, All rights reserved. Material Design is a design language developed by Google. Material Design makes more liberal use of grid-based layouts and responsive animations and transitions.
Powered by VanillaForums, Designed by ThemeSteam

Contact us

info@example.com
support@example.com
(800) 3032120

Get In Touch