Jump to content

Printf Query


Naps

Recommended Posts

Quick question regarding the printf function.

 

I understand that printf will print a formatted string for example:

 

$mystring = printf('%.1f', 1.2); //Will output 1.2

 

However I don't understand why if I then print $mystring the result is 3

 

Example:

$mystring = printf('%.1f', 1.2); //prints 1.2
echo "<br><br>";
echo $mystring  //Prints 3

 

Please could someone explain how this works?

 

Link to comment
https://forums.phpfreaks.com/topic/258264-printf-query/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.