• Strings and regular expressions

      0 comments

    What will be the answer of the following code snippet?

    echo 'Testing ' . 1 + 2 . '45';
    

    Simply you will give the answer as : Testing 345

    But the answer is : 245

    That is because you can not sum a number with a string. The first part, before the plus mark is a string though there is 1 there.
    So engine will simply get it as 0 and the latter part as 245. so answer will be 245.