Portrety Uliczne Nieznajomych - zobacz wyjątkową galerię portretów z warszawskich ulic
ZALOGUJ SIĘ
login:
hasło:
przypomnij hasło
załóż konto użytkownika
(i zobacz kilka porad gratis)
   
WYSZUKIWARKA I DZIAŁY
całe porady  tytuły
zaznacz działy do przeszukania
(brak wyboru = wszystkie działy)
PHP
MySQL >
PostgreSQL
SQLite
Perl
Java
XML
XSLT
XPath
WML
SVG
RegExp
Wyszukiwarki
Ochrona
VBScript
Google Plus
XHTML/CSS
JavaScript
Grafika
Flash
Photoshop
Windows
Linux
Bash
Apache
Procmail
E-biznes
Explorer
Opera
Firefox
Inne porady
   
KURSY, DOKUMENTACJE
Własne:
XHTML/CSS
JavaScript
ActionScript
WML, RSS, SSI
Pozostałe:
PHP
MySQL
Java API
więcej...
   
użytkowników online: 59
W CZYM MOGĘ POMÓC?


   
OPINIE UŻYTKOWNIKÓW
Prawdziwa skarbnica wiedzy na temat tworzenia stron WWW i nie tylko. Korzystam z porad praktycznie codziennie, jest mi to niezbędne w mojej pracy. Sam zajmuję się tworzeniem serwisów, ale porady pisane przez Darka sa dla mnie nieocenioną pomocą! Proste, czytelne i zrozumiałe dla każdego! Czekam na więcej!

Krzysztof Szypulski
KESS - projektowanie stron

   
GALERIA FOTOGRAFII
   
PODRĘCZNIK PHP 5.x, 4.x, 3.x - częściowo spolszczony / źródło: www.php.net

[Spis] [A] [B] [C] [D] [E] [F] [G] [H] [I] [J] [K] [L] [M] [N] [O] [P] [Q] [R] [S] [T] [U] [V] [X] [W] [Z]

file_put_contents

(PHP 5)

file_put_contents -- Write a string to a file

Description

int file_put_contents ( string filename, mixed data [, int flags [, resource context]] )

Identical to calling fopen(), fwrite(), and fclose() successively. The function returns the amount of bytes that were written to the file.

flags can take FILE_USE_INCLUDE_PATH and/or FILE_APPEND, however the FILE_USE_INCLUDE_PATH option should be used with caution.

You can also specify the data parameter as an array (not multi-dimension arrays). This is equivalent to file_put_contents($filename, join('', $array)).

Notatka: Wsparcie dla kontekstów zostało dodane w PHP 5.0.0.

As of PHP 5.1.0, you may also pass a stream resource to the data parameter. In result, the remaining buffer of that stream will be copied to the specified file. This is similar with using stream_copy_to_stream().

Notatka: Ta funkcja jest bezpieczna dla danych binarnych.

Podpowiedź: Jeśli włączona jest dyrektywa konfiguracyjna fopen wrappers, możliwe jest podanie jako nazwy pliku adresu URL. Zobacz opis funkcji fopen() aby dowiedzieć się jak przekazać nazwę pliku, oraz fopen wrappers aby uzyskać listę obsługiwanych protokołów.

See also fopen(), fwrite(), fclose(), and file_get_contents().




User Contributed Notes

oveaurs at gmail dot com
30-Jan-2006 02:51

From previous comment:
for php4
<?php
function file_put_contents($file, $string) {
  
$f=fopen($file, 'a+');
  
ftruncate($f, 0);
  
fwrite($f, $string);
  
fclose($f);
}
?>

why not call fopen with 'w' instead of 'a+'? :
<?php
function file_put_contents($file, $string) {
  
$f=fopen($file, 'w');
  
fwrite($f, $string);
  
fclose($f);
}
?>


20-Jan-2006 06:09

for php4
<?php
function file_put_contents($file, $string) {
  
$f=fopen($file, 'a+');
  
ftruncate($f, 0);
  
fwrite($f, $string);
  
fclose($f);
}
?>


pvenegas+php at gmail dot com
12-Oct-2005 04:13

Note that if the specified file already exists, this function effectively discards its contents (equivalent to fopen with 'w') and inserts the new data. The documentation doesn't say this explicitly, so this might help those who are unsure.


Jared Kuolt
04-Mar-2005 09:14

Note that this function will create the file if it does not exists, assuming PHP has write access to the folder.


aidan at php dot net
21-May-2004 04:11

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


 

 
  © 1996-2012 & Reporter.plmiejscao serwisieabonamentwarunki korzystaniaRSSkontakt