Explication de...(php)

Résolu/Fermé
maxime_B Messages postés 788 Date d'inscription mardi 14 juin 2005 Statut Membre Dernière intervention 15 juin 2010 - 30 juin 2006 à 18:54
jisisv Messages postés 3645 Date d'inscription dimanche 18 mars 2001 Statut Modérateur Dernière intervention 15 janvier 2017 - 1 juil. 2006 à 09:55
bonjour

ça veut dire quoi et ça sert à quoi

sprintf()


en php??

merci devos réponses

1 réponse

jisisv Messages postés 3645 Date d'inscription dimanche 18 mars 2001 Statut Modérateur Dernière intervention 15 janvier 2017 934
1 juil. 2006 à 09:55
Al même chose qu'en C ;)
http://php.easynet.be/manual/fr/function.sprintf.php
exemples
<?php
$st1 = "Hello World";
$pi = 3.1415;

$st = sprintf("The string is %s\n", $st1);
print $st;
$st = sprintf("The string is %25s\n", $st1);
print $st;
$st = sprintf("The string is %'b25s\n", $st1);
print $st;
$st = sprintf("The float is %.7f\n", $pi);
print $st;
$st = sprintf("The float is %10.4f\n", $pi);
print $st;
$st = sprintf("The float is %08f", $pi);
print $st;
?>
johand@horus:~/src/php$ php sprintf.php
The string is Hello World
The string is               Hello World
The string is bbbbbbbbbbbbbbHello World
The float is 3.1415000
The float is     3.1415
The float is 3.141500

Johan
-1