0

What will happen if I add "Anshul" and "1995" ??

2nd Jan 2017, 7:25 AM
Anshul Shivhare
Anshul Shivhare - avatar
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;
4th Jan 2017, 1:55 AM
Eric Sizemore
Eric Sizemore - avatar
0
It will return '1995' as PHP will cast 'Anshul' to int (which will be 0). <?php $name = 'Anshul'; $year = '1995'; echo $name + $year; ?>
3rd Jan 2017, 3:28 AM
Eric Sizemore
Eric Sizemore - avatar
0
you're right Eric.
4th Jan 2017, 2:39 AM
Louis Milotte
Louis Milotte - avatar
- 1
<?php $name = 'Anshul'; $year = '1995';//this is a string. echo $name + $year; //the actual output is Anshul1995 ?>
3rd Jan 2017, 4:55 PM
Louis Milotte
Louis Milotte - avatar