Jump to: navigation, search

Php file get contents

From w3cyberlearnings

Contents

PHP function file_get_contents

This function reads the file content into a string.

Syntax file_get_contents

  • file: file name
  • include_path (optional): Set to true, search the file in the include_path in php.ini as well.
  • context(optional): a valid context, and you can set to NULL if you don't use it.
  • offset(optional): Specifies the file to start reading.
  • maxlength(optional): specifies how many bites to read.
file_get_contents(file, include_path, context, offset, maxlength);

Note

If you access the URI with special characters, such as space, you need to encode the URI with urlencode().

Example 1

<?php

$content = file_get_contents("mycontent.txt");
echo $content;
?>

Example 2

<?php

$content = file_get_contents("http://www.w3cyberlearnings.com/");

echo $content;
?>

Related Links


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-- lchgrp-- lchown-- link-- linkinfo-- lstat-- mkdir-- move_uploaded_file-- parse_ini_file-- parse_ini_string-- pathinfo-- pclose-- popen-- readfile-- readlink-- realpath_cache_get-- realpath_cache_size-- realpath-- rename-- rewind-- rmdir-- set_file_buffer-- stat-- symlink-- tempnam-- tmpfile-- touch-- umask-- unlink--

Navigation
Web
SQL
MISC
References