Skip to main content
deleted 37 characters in body
Source Link
Marcin Orlowski
  • 75.7k
  • 11
  • 128
  • 152

I written the following tiny php program to test printf and sprintf:

<?php
    $text = "65 127 245";
    $str_1 = printf("%x%x%x", 65, 127, 245);
    $str_2 = sprintf("%x%x%x", 65, 127, 245);
    
    echo $str_1 . "\n";
    echo $str_2 . "\n";
?>

the output is this:

417ff56
417ff5

why I have that 6 digit in the first line of output?

I written the following tiny php program to test printf and sprintf:

<?php
    $text = "65 127 245";
    $str_1 = printf("%x%x%x", 65, 127, 245);
    $str_2 = sprintf("%x%x%x", 65, 127, 245);
    
    echo $str_1 . "\n";
    echo $str_2 . "\n";
?>

the output is this:

417ff56
417ff5

why I have that 6 digit in the first line of output?

I written the following tiny php program to test printf and sprintf:

<?php
    $str_1 = printf("%x%x%x", 65, 127, 245);
    $str_2 = sprintf("%x%x%x", 65, 127, 245);
    
    echo $str_1 . "\n";
    echo $str_2 . "\n";

the output is this:

417ff56
417ff5

why I have that 6 digit in the first line of output?

Source Link
Sam
  • 485
  • 2
  • 9
  • 18

php - printf and sprintf have different outputs

I written the following tiny php program to test printf and sprintf:

<?php
    $text = "65 127 245";
    $str_1 = printf("%x%x%x", 65, 127, 245);
    $str_2 = sprintf("%x%x%x", 65, 127, 245);
    
    echo $str_1 . "\n";
    echo $str_2 . "\n";
?>

the output is this:

417ff56
417ff5

why I have that 6 digit in the first line of output?