PHP4 new functions

Source: Internet
Author: User

These functions allow you to control the content output by your script. it can be used in many different situations, especially when your script has output information, you need to send a new file header. the output control function does not affect the header information sent using header () or setcookie (). It only applies to data blocks similar to echo () and PHP code.
Example 1. control output
<? Php
Ob_start ();
Echo "Hellon ";
Setcookie ("cookiename", "cookiedata ");
Ob_end_flush ();
?>
In the preceding example, the output content using echo () is saved in the output buffer until ob_end_flush () is called (). it makes sense that the content that calls setcookie () is successfully stored in the cookie without causing errors. (normally, you cannot send the file header information to your browser after the data has been sent .)
Related Function header () and setcookie ().
Korea list
Flush-refresh the output buffer
The content stored in the output buffer is sent to the browser.
Ob_start-open the output buffer
In this way, all output information is not directly sent to the browser, but saved in the output buffer.
Ob_get_contents-return the content of the output buffer
If you want to process the output content in the future, you can call this function to keep a backup.
Ob_get_length-return the content length of the output buffer
Ob_end_flush-end (send) output buffer content, disable the output buffer
Ob_end_clean-delete (discard) the output buffer and disable the output buffer.
If your program finds a problem with the output content, you can discard all output content to prevent leakage of some confidential information.
Ob_implicit_flush-Refresh directly when it is enabled or disabled
After the script is opened, the output of each script is directly sent to the browser, and you do not need to call flush ()
Ii. Obtain the current directory
This is the new directory function of php4!
String getcwd (void)
Returns the string of the current script path!
Iii. Fixed script timeout
In php configuration/information, there is a function for setting the script execution time, as shown below:
Set_time_limit
Configure the longest execution time for this page.
Syntax: void set_time_limit (int seconds );
Return Value: None
Function types: PHP system functions
Description
This function is used to configure the longest execution time of the page. The default value is 30 seconds. in php. ini, The max_execution_time variable is configured. If it is set to 0, the maximum time is not limited. Computing starts only when the function is executed. For example, if the default value is 30 seconds, and 25 seconds have been executed before the function is executed, and the function is changed to 20 seconds, the maximum execution time of the page is 45 seconds.

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.