Php basic functions

Source: Internet
Author: User
Introduction to php basic functions: this is a detailed page of php basic functions. it introduces php related knowledge, skills, experience, and some php source code.

Class = 'pingjiaf' frameborder = '0' src = 'http: // biancheng.dnbc?info/pingjia.php? Id = 335085 'Scrolling = 'no'> define a constant
Define ('appconfig', 'pluaconfig ');
Returns a constant.
Echo constant ('appconfig'). "\ n ";
The constant cannot be defined twice.

Initialize variable value
Ini_set ('display _ errors ', 1 );
Obtain the variable value.
Echo ini_get ('display _ errors '). "\ n ";


PHP
Ob_start ();

Related functions:
1. Flush: refresh the buffer content and output it.
Function format: flush ()
Note: This function is frequently used and highly efficient.
2. ob_start: Open the output buffer.
Function format: void ob_start (void)
Note: When the buffer zone is activated, all non-file header information from the PHP program is not sent, but stored in the internal buffer zone. To output the buffer content, you can use ob_end_flush () or flush () to output the buffer content.
3. ob_get_contents: returns the content of the internal buffer.
Usage: string ob_get_contents (void)
Note: This function returns the content in the current buffer. if the output buffer is not activated, FALSE is returned.
4. ob_get_length: return the length of the internal buffer.
Usage: int ob_get_length (void)
Note: This function returns the length of the current buffer. it is the same as ob_get_contents if the output buffer is not activated. Returns FALSE.
5. ob_end_flush: sends the content of the internal buffer to the browser and closes the output buffer.
Usage: void ob_end_flush (void)
Note: This function sends the content of the output buffer (if any ).
6. ob_end_clean: delete the content of the internal buffer and disable the internal buffer.
Usage: void ob_end_clean (void)
Note: This function will not output the content of the internal buffer but delete it!
7. ob_implicit_flush: enable or disable absolute refresh
Usage: void ob_implicit_flush ([int flag])
Note: Anyone who has used Perl knows the meaning of $ | = x. This string can enable/disable the buffer, while the ob_implicit_flush function is the same as that. the buffer is disabled by default, after the absolute output is enabled, each script output is directly sent to the browser, and you do not need to call flush ()


Example:

Ob_start ();
Echo "hello \ n ";
$ C = ob_get_contents ();
Ob_end_flush ();
Echo "cache =". $ c;
?>

Output:
Hello
Cache = hello



$ T0 = 0;
$ S0 = 0;
$ T1 = 0;
$ S1 = 0;
$ T2 = 0;
$ S2 = 0;
$ T3 = 0;
$ S3 = 0;
If (ob_get_level ()){
$ T0 = 1;
$ S0 = ob_get_level ();
}
Ob_start ();
If (ob_get_level ()){
$ T1 = 1;
$ S1 = ob_get_level ();
}
Ob_start ();
If (ob_get_level ()){
$ T2 = 1;
$ S2 = ob_get_level ();
}
Ob_start ();

If (ob_get_level ()){
$ T3 = 1;
$ S3 = ob_get_level ();
}
Ob_end_flush ();
Ob_end_flush ();
Ob_end_flush ();
Echo "t0 =". $ t0. "\ n ";
Echo "s0 =". $ s0. "\ n ";
Echo "t1 =". $ t1. "\ n ";
Echo "s1 =". $ s1. "\ n ";
Echo "t2 =". $ t2. "\ n ";
Echo "s2 =". $ s2. "\ n ";
Echo "t3 =". $ t3. "\ n ";
Echo "s3 =". $ s3. "\ n ";


Output:
T0 = 0
S0 = 0
T1 = 1
S1 = 1
T2 = 1
S2 = 2
T3 = 1
S3 = 3

Die ()
The function outputs a message and exits the current script.

This is the alias of the exit () function.
Syntax

Die (status)

Parameter description
Status is required. Specifies the message or status number written before exiting the script. The status number is not written to the output.
Description

If status is a string, the function outputs the string before exiting.

If status is an integer, this value is used as the exit status. The exit status ranges from 0 to 254. Exit status 255 is retained by PHP and will not be used. Status 0 is used to successfully terminate the program.


File_exists ()
Whether the file exists,
Is_readable ()
Whether the file is readable
Realpath ()
Absolute path

More articles on "php basic functions"

Love J2EE follow Java Michael Jackson video station JSON online tools

Http://biancheng.dnbcw.info/php/335085.html pageNo: 10.

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.