0
What will happen if I add "Anshul" and "1995" ??
4 Respostas
+ 1
@Louis
I'm not sure how you're getting anything other than 1995. In this example PHP will discard the actual string. only the int (even as a string) will be returned. The only way to get 'Anshul1995' is concatenation:
echo $name . $year;
0
It will return '1995' as PHP will cast 'Anshul' to int (which will be 0).
<?php
$name = 'Anshul';
$year = '1995';
echo $name + $year;
?>
0
you're right Eric.
- 1
<?php
$name = 'Anshul';
$year = '1995';//this is a string.
echo $name + $year;
//the actual output is Anshul1995
?>