downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | conferences | my php.net

search for in the

get_html_translation_table> <explode
[edit] Last updated: Fri, 24 May 2013

view this page in

fprintf

(PHP 5)

fprintfBiçemli dizgeyi bir akıma yazar

Açıklama

int fprintf ( resource $dt , string $biçem [, mixed $değiştirgeler [, mixed $... ]] )

Tanıtıcısı dt ile belirtilen dosyaya (akıma) biçem dizgesine göre üretilen dizgeyi yazar.

Değiştirgeler

dt

Bir dosya tanıtıcısı. Genellikle fopen() kullanılarak oluşturulur.

biçem

biçem dizgesinin açıklaması için sprintf() işlevine bakınız.

değiştirgeler

...

Dönen Değerler

Akıma yazılan dizgenin uzunluğunu döndürür.

Örnekler

Örnek 1 - fprintf(): Sıfır dolgulu tamsayılar

<?php
if (!($fp fopen('date.txt''w'))) {
    return;
}

fprintf($fp"%04d-%02d-%02d"$year$month$day);
// ISO biçemli tarihi date.txt dosyasına yazar
?>

Örnek 2 - fprintf(): para biçemleme

<?php
if (!($fp fopen('currency.txt''w'))) {
    return;
}

$money1 68.75;
$money2 54.35;
$money $money1 $money2;
// echo $money çıktısı: "123.1";
$len fprintf($fp'%01.2f'$money);
// currency.txt dosyasına "123.10" yazar

echo "currency.txt dosyasına $len bayt yazıldı";
// Kaç bayt yazıldığını belirtmek için fprintf dönüş değerini kullanıyoruz
?>

Ayrıca Bakınız

  • printf() - Biçemli bir dizge çıktılar
  • sprintf() - Biçemli bir dizge döndürür
  • sscanf() - Girdi dizgesini belli bir biçeme göre yorumlar
  • fscanf() - Bir dosyadaki girdiyi belli bir biçeme göre çözümler
  • vsprintf() - Biçemli bir dizge döndürür
  • number_format() - Sayıyı binlik bölümlere ayırır



add a note add a note User Contributed Notes fprintf - [2 notes]
up
-1
jgbreezer at hotmail dot com
6 years ago
Another alternative using sprintf and fwrite() for pre-v5 php's:

fwrite( resource, sprintf(format [, mixed args [, mixed ...]] ))

Barring slight logical differences in meaning of returned value and (maybe??) how it handles magic_quotes_runtime config option, see fwrite() help.
up
-2
aidan at php dot net
8 years ago
This functionality is now implemented in the PEAR package PHP_Compat.

More information about using this function without upgrading your version of PHP can be found on the below link:

http://pear.php.net/package/PHP_Compat

 
show source | credits | stats | sitemap | contact | advertising | mirror sites