PHP5 Manual Free Open Book

PHP5 Manual

PHP Manual
PrevNext

file_get_contents

(PHP 4 >= 4.3.0, PHP 5)

file_get_contents -- Reads entire file into a string

Description

string file_get_contents ( string filename [, bool use_include_path [, resource context [, int offset [, int maxlen]]]] )

Identical to file(), except that file_get_contents() returns the file in a string, starting at the specified offset up to maxlen bytes. On failure, file_get_contents() will return FALSE.

file_get_contents() is the preferred way to read the contents of a file into a string. It will use memory mapping techniques if supported by your OS to enhance performance.

Note: If you're opening a URI with special characters, such as spaces, you need to encode the URI with urlencode().

Note: context parameter can be skipped by NULL.

ChangeLog

VersionDescription
5.0.0 Added the context support.
5.1.0 Added the offset and maxlen parameters.

Notes

Note: This function is binary-safe.

Tip: You can use a URL as a filename with this function if the fopen wrappers have been enabled. See fopen() for more details on how to specify the filename and Appendix M for a list of supported URL protocols.

Note: Context support was added with PHP 5.0.0. For a description of contexts, refer to Reference CL, Stream Functions.

Warning

When using SSL, Microsoft IIS will violate the protocol by closing the connection without sending a close_notify indicator. PHP will report this as "SSL: Fatal Protocol Error" when you reach the end of the data. To workaround this, you should lower your error_reporting level not to include warnings. PHP 4.3.7 and higher can detect buggy IIS server software when you open the stream using the https:// wrapper and will suppress the warning for you. If you are using fsockopen() to create an ssl:// socket, you are responsible for detecting and suppressing the warning yourself.


     Main Menu
PHP Manual
Table of Contents
Preface
Getting Started
Language Reference
Security
Features
Function Reference
Apache-specific Functions
Advanced PHP debugger
Array Functions
Aspell functions [deprecated]
BCMath Arbitrary Precision Mathematics Functions
PHP bytecode Compiler
Bzip2 Compression Functions
Calendar Functions
CCVS API Functions [deprecated]
Classkit Functions
Class/Object Functions
COM and .Net (Windows)
ClibPDF Functions
Crack Functions
Character Type Functions
CURL, Client URL Library Functions
Cybercash Payment Functions
Cyrus IMAP administration Functions
Date and Time Functions
Database (dbm-style) Abstraction Layer Functions
dBase Functions
DBM Functions [deprecated]
DB++ Functions
dbx Functions
Direct IO Functions
Directory Functions
DOM Functions
DOM XML Functions
.NET Functions
Error Handling and Logging Functions
Program Execution Functions
Exif Functions
File Alteration Monitor Functions
FrontBase Functions
Forms Data Format Functions
filePro Functions
Filesystem Functions
basename
chgrp
chmod
chown
clearstatcache
copy
delete
dirname
disk_free_space
disk_total_space
diskfreespace
fclose
feof
fflush
fgetc
fgetcsv
fgets
fgetss
file_exists
file_get_contents
file_put_contents
file
fileatime
filectime
filegroup
fileinode
filemtime
fileowner
fileperms
filesize
filetype
flock
fnmatch
fopen
fpassthru
fputcsv
fputs
fread
fscanf
fseek
fstat
ftell
ftruncate
fwrite
glob
is_dir
is_executable
is_file
is_link
is_readable
is_uploaded_file
is_writable
is_writeable
link
linkinfo
lstat
mkdir
move_uploaded_file
parse_ini_file
pathinfo
pclose
popen
readfile
readlink
realpath
rename
rewind
rmdir
set_file_buffer
stat
symlink
tempnam
tmpfile
touch
umask
unlink
FriBiDi Functions
FTP Functions
Function Handling Functions
Gettext
GMP Functions
HTTP Functions
Hyperwave Functions
Hyperwave API Functions
Firebird/InterBase Functions
IBM DB2, Cloudscape and Apache Derby Functions
ICAP Functions [deprecated]
iconv Functions
ID3 Functions
Informix Functions
IIS Administration Functions
Image Functions
IMAP, POP3 and NNTP Functions
PHP Options&Information
Ingres II Functions
IRC Gateway Functions
PHP / Java Integration
LDAP Functions
libxml Functions
LZF Functions
Mail Functions
mailparse Functions
Mathematical Functions
MaxDB PHP Extension
Multibyte String Functions
MCAL Functions
Mcrypt Encryption Functions
MCVE Payment Functions
Memcache Functions
Mhash Functions
Mimetype Functions
Ming functions for Flash
Miscellaneous Functions
mnoGoSearch Functions
Mohawk Software Session Handler Functions
mSQL Functions
Microsoft SQL Server Functions
muscat Functions
MySQL Functions
Improved MySQL Extension
Ncurses Terminal Screen Control Functions
Network Functions
YP/NIS Functions
Lotus Notes Functions
NSAPI-specific Functions
Object Aggregation/Composition Functions
Oracle 8 functions
OpenAL Audio Bindings
OpenSSL Functions
Oracle Functions
Output Control Functions
Object property and method call overloading
Ovrimos SQL Functions
Parsekit Functions
Process Control Functions
Regular Expression Functions (Perl-Compatible)
PDF functions
PDO Functions
Verisign Payflow Pro Functions
PostgreSQL Functions
POSIX Functions
Printer Functions
Pspell Functions
qtdom Functions
Rar Functions
GNU Readline
GNU Recode Functions
Regular Expression Functions (POSIX Extended)
Semaphore, Shared Memory and IPC Functions
SESAM Database Functions
Session Handling Functions
Shared Memory Functions
SimpleXML functions
SNMP Functions
SOAP Functions
Socket Functions
Standard PHP Library (SPL) Functions
SQLite Functions
Secure Shell2 Functions
Stream Functions
String Functions
Shockwave Flash Functions
Sybase Functions
TCP Wrappers Functions
Tidy Functions
Tokenizer Functions
ODBC Functions (Unified)
URL Functions
Variable Handling Functions
vpopmail Functions
W32api Functions
WDDX Functions
xattr Functions
xdiff Functions
XML Parser Functions
XML-RPC Functions
XSL functions
XSLT Functions
YAZ Functions
Zip File Functions (Read Only Access)
Zlib Compression Functions
Zend API
PHP API: Interfaces for extension writers
FAQ: Frequently Asked Questions
Appendixes
Copyright


More Books
PHP Hacks
Processing Xml With Java - A Guide To Sax, Dom, Jdom, Jaxp, And Trax
The Koran (Holy Qur'an)
Macromedia Flash 8 Bible
Search Engine Optimization for Dummies
YouTube Traffic
PHP 5 for Dummies
Harry Potter and The Chamber of Secrets
Harry Potter and the Sorcerer's Stone
The Pilgrim's Progress
Wireless Hacks
Flash Hacks. 100 Industrial-Strength Tips & Tools
PayPal Hacks. 100 Industrial-Strength Tips and Tools
Amazon Hacks
Pdf Hacks
The Da Vinci Code
Google Hacks
The Holy Bible
Windows XP For Dummies
Harry Potter and the Half-Blood Prince
Seo Book
Upgrading and Repairing Networks
Macromedia Dreamweaver 8 UNLEASHED
Windows XP Annoyances
Windows XP Hacks
Microsoft Windows XP Power Toolkit
Teach Yourself MS Office In 24Hours
iPod & iTunes Missing Manual
PC Hacks 100 Industrial-Strength Tips and Tools
PC Overclocking, Optimization, and Tuning - 2th Edition
PC Hardware In A Nutshell 3rd Edition
PC Hardware in a Nutshell, 2nd Edition
Upgrading and Repairing PCs
Google for Dummies
MySQL Cookbook
Teach Yourself Macromedia Flash 8 In 24 Hours
PHP CookBook
Sams Teach Yourself JavaScript in 24 Hours
PHP5 Manual
Free Games Paper Airplanes
500 Juegos Gratis 500 Giochi Gratis 500 Jeux Gratuits 500 Jogos Gratis 500 Kostenlose Spiele