Friday, 4 August 2017

php amazing question and logical answer

php  amazing question and logical answer

Question: What is output of 1...1?
Its Output is 10.1
How?
Divide it into three points.
1.
.
.1

  1. 1.0 is equal to 1
  2. 2nd . is a concatenation operator
  3. .1 is equal to 0.1
  4. So {1} {.} {0.1} is EQUAL to 10.1



Question: What is final value of $a, $b in following?
$a = '1';
$b = &$a;
$b = "2$b";
echo $a;
echo $b;
output
21
21

Explaination
$a = '1'; //1
$b = &$a; //both are equal
$b = "2$b"; //now $b=21
echo $a;  //21
echo $b; //21



Question: What is output of 016/2?
Output is : 7. The leading zero indicates an octal number in PHP, so the decimal number 14 instead to decimal 16;
echo 016; //14
echo 016/2; //7



No comments :

Post a Comment