Hello today I was reading about printf in PHP. printf outpust a formatted string. I have a string. I was about to format the floating point string like
$str = printf('%.1f',5.3);
I know about format %.1f means. Here 1 is number of decimal places. If I echo $str like
echo $str;
It outputs
5.33
I can understand the output because 5.3 is the string and 3 is the lenght of outputed string which is the return value of printf.
But see my following code
$str = printf('%.1f', '5.34');
echo 'ABC';
echo $str;
It outputs
5.3ABC3
I wonder how it is happening? If we go simple PHP interpolation it should output ABC first then it should output 5.33 because we are formatting only 5.33 not ABC.
Can any one guide me what is happening here?