Read file PHP read output other file method

Source: Internet
Author: User
Tags fread
Ob_start ();
Iconv (' Utf-8 ', ' gb2312 ', ReadFile (' 1.html ')); Direct output of text content
Echo ';

$data = file_get_contents ('./1.html ', null,null,0,10);
Var_dump ($data);//Output string
Echo ';


$data = File ('./1.html ');
Var_dump ($data);//output array
Echo ';

$stream = fopen ('./1.html ', ' R ');
Echo stream_get_contents ($stream, 12);//Output string
Echo ';

Fread () reads files (which are safe for binary files) file system pointers, which are typically resource (resources) created by fopen ().
$data = fopen ('./1.html ', ' RB ');
$contents = Fread ($data, FileSize ('./1.html '));
echo $contents;//Output string

The above describes the read file PHP read output other files, including reading the contents of the file, I hope the PHP tutorial interested in a friend helpful.

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.