Formattare i numeri con printf()

$number = 15;
printf("Decimal: %d", $number);	//Decimal: 15
printf("Binary: %b", $number);	//Binary: 1111
printf("Double: %f", $number);	//Double: 15.000000
printf("Octal: %o", $number);	//Octal: 17
printf("String: %s", $number);	//String: 15
printf("Hex (lower): %x", $number);	//Hex (lower): f
printf("Hex (upper): %X", $number);	//Hex (upper): F

Pubblicato

in

da

Tag: