A collection of PHP4 new functions

Source: Internet
Author: User
These functions allow you to control the content of your script output. Can be used in a number of different situations, especially if your script has already output information and needs to send a new file header. The output control function does not affect the header information that is sent using header () or Setcookie (), but only those similar to Echo () and PHP code data blocks are useful.
Example 1. Control output
<?php
Ob_start ();
echo "Hellon";
Setcookie ("CookieName", "Cookiedata");
Ob_end_flush ();
?>
In the above example, the output with Echo () is saved in the output buffer until the Ob_end_flush () is invoked. What makes sense is that the contents of the call Setcookie () are stored successfully in the cookie without causing an error. (Normally, you cannot send file header information to the user's browser after the data has been sent.)
The correlation function header () and Setcookie ().
Korean Series table
flush-Flush Output Buffer
Content saved in the output buffer is sent to the browser
ob_start-Open Output Buffer
So all the output information is not sent directly to the browser, but is stored in the output buffer
ob_get_contents-returns the contents of the output buffer
If you want to process the output later, you can call this function to keep a backup
ob_get_length-returns the content length of the output buffer
ob_end_flush-End (send) output buffer content, turn off output buffer
ob_end_clean-Deletes (discards) the contents of the output buffer and closes the output buffer
If your program finds that there is a problem with the output, you can discard all output and prevent some secret information from leaking
ob_implicit_flush-turn on or off direct refresh
Once opened, each script output is sent directly to the browser and no longer needs to invoke flush ()
Second, get the current directory
This is the new directory function for PHP4!
String getcwd (void)
Returns the string for the current script path!
Third, the resolution script timeout
There is a function in PHP configuration/information that sets the execution time of the script, as follows:
Set_time_limit
Configure the page for the longest execution time.
Syntax: void set_time_limit (int seconds);
return value: None
Function type: PHP system function
Content Description
This function configures the longest execution time for the page. The default value is 30 seconds, the Max_execution_time variable is configured in PHP.ini, and if configured to 0 it is not limited to the longest time. The calculation begins when the function is executed. For example, if the default is 30 seconds and 25 seconds have been executed before executing to the function, and the function is changed to 20 seconds, the maximum execution time for 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.