MemoryRefresh!

Aritmetic



Questions 1 Answers 0%

Pages   0 from 51
Questions   0 from 84

Reset



If the operator is placed after its operand, the interpreter will first return the value of the latter (unchanged), and then either increment or decrement it by one. Use with care.
<?php $a = 1; echo $a++; // output 1 echo $a; // output 2 $a = 1; echo ++$a; // output 2 echo $a; // output 2 Incrementing or decrementing booleans has no effect
<?php $a = TRUE; echo ++$a; // 1 echo $a; // 1 PHP follows Perl's convention when dealing with arithmetic operations on character variables.
<?php $i = 'W'; for ($n=0; $n<6; $n++) { echo ++$i . "n"; } // output X Y Z AA AB AC
Questions

Related pages

Aritmetic !
String !
Comparison !
Logical !
Bitwise !


0% 100%
 
 
0 pages 51 pages
1) What is the output of the following code? <?php $a = 1; echo $a++; echo ++$a;





2) What's the result when incrementing boolean? <?php $a = TRUE; echo ++$a;




3) What's the result when incrementing chars? <?php $a = "Y"; $b = ++$a; echo $b; $c = ++$b; echo $c;





Last Review: n/a   Passed: n/a   Reviews: n/a   Next Review: n/a  


If the operator is placed after its operand, the interpreter will first return the value of the latter (unchanged), and then either increment or decrement it by one. Use with care.
<?php $a = 1; echo $a++; // output 1 echo $a; // output 2 $a = 1; echo ++$a; // output 2 echo $a; // output 2 Incrementing or decrementing booleans has no effect
<?php $a = TRUE; echo ++$a; // 1 echo $a; // 1 PHP follows Perl's convention when dealing with arithmetic operations on character variables.
<?php $i = 'W'; for ($n=0; $n<6; $n++) { echo ++$i . "n"; } // output X Y Z AA AB AC



More from Php

Basics
Variables
Operators
Function
Array
String
Streams
Uncategorized


More from Programming

Php
jQuery




Powered by minte9.com