PHP Replacement template variable Implementation step analysis

Source: Internet
Author: User
Tags fread

PHP Replacement template variable Implementation Step analysis, we can refer to the next.

650) this.width=650; "src=" Http://183.61.143.148/group1/M00/02/3D/tz2PlFQztVuCE62GAABoN2MrxOs933.png "/>

1. First, you need to open a file. PHP->fopen () is used here; function

Definition and Usage
The fopen () function opens the file or URL.
If open fails, this function returns FALSE.
function Prototypes:
fopen (Filename,mode,include_path,context)
Description
fopen () binds the name resource specified by filename to a stream. If filename is "scheme://..." Format, the Search protocol processor (also known as the Encapsulation Protocol) is treated as a url,php to handle this pattern. If the protocol has not yet been registered for encapsulation, PHP will issue a message to help examine potential problems in the script and continue with filename as a normal file name.
if PHP thinks that filename specifies a local file, it will attempt to open a stream on that file. The file must be accessible by PHP, so you need to confirm that the file access permission allows that access. If Safe mode is activated or open_basedir is applied, further restrictions apply.
if PHP believes that filename specifies a signed protocol, and that the protocol is registered as a network url,php will check and confirm that Allow_url_fopen has been activated. If it is off, PHP will issue a warning, and fopen's call fails.
support for the context is added by PHP 5.0.0.
Hints and notes
Note: For portability, it is strongly recommended that you always use the "B" flag when opening a file with fopen ().
2. After opening this file, read the file. PHP->fread () is used here; function
Definition and Usage
The fread () function reads the file (which can be used safely in binary files).
function Prototypes:
fread (file,length)//Note: I didn't know. The file that this function obtains is the file size by byte (byte) ....
Description
fread () reads up to length bytes from file pointer files. The function stops reading the file when it has read up to the maximum length of bytes, or when it reaches EOF, or (for a network stream) when a package is available, or when 8,192 bytes have been read (after opening a stream of user space), depending on which situation is encountered first.
Returns the read string if an error returns false.
Hints and notes
Tip: If you just want to read the contents of a file into a string, use file_get_contents (), which has a much better performance than fread ().

want to know more Programming Language Tutorials Knowledge Please login e mentor Net .


This article is from the "Add Language" blog, please make sure to keep this source http://yuguotianqing.blog.51cto.com/9292883/1561880

PHP Replacement template variable Implementation step analysis

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.