PHP4 new Function Collection _php tutorial

Source: Internet
Author: User
These functions allow you to control the content of your script output. It can be used in many different situations, especially if your script has output information that requires a new file header to be sent. The output control function does not affect the header information sent with header () or Setcookie (), only those that are similar to The data blocks of Echo () and PHP code are useful.
Example 1. Control output
Ob_start ();
echo "Hellon";
Setcookie ("CookieName", "Cookiedata");
Ob_end_flush ();
?>
In the example above, the output using echo () will be saved in the output buffer until Ob_end_flush () is called. What makes sense is that the content of the call to Setcookie () is successfully stored in the cookie without causing an error. (Under normal circumstances, you can not send the file header information to the user's browser after the data has been sent.)
The associated function header () and Setcookie ().
List of Korean series
flush-Flush Output Buffers
The content that is saved in the output buffer is sent to the browser
ob_start-opening the output buffer
In this way, all 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) the contents of the output buffer, close the output buffer
ob_end_clean-Delete (Discard) The contents of the output buffer, close the output buffer
If your program finds a problem with the output, you can discard any output and prevent the disclosure of some secret information.
ob_implicit_flush-turn direct refresh on or off
Once opened, each script output is sent directly to the browser, eliminating the need to call flush ()
Second, get the current directory
This is the new directory function of PHP4!
String getcwd (void)
Returns a string for the current script path!
Third, resolve the script timeout
In the PHP configuration/information There is a function to set the execution time of the script, as follows:
Set_time_limit
Configures 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 is used to configure the longest execution time of the page. The default value is 30 seconds, and the max_execution_time variable configuration in php.ini, if configured to 0, is not limited to the longest time. The calculation is only started when the function is executed. For example, if the default 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 for the page is 45 seconds.

http://www.bkjia.com/PHPjc/629515.html www.bkjia.com true http://www.bkjia.com/PHPjc/629515.html techarticle These functions allow you to control the content of your script output. It can be used in many different situations, especially if your script has output information that requires a new file header to be sent. Output Control ...

  • 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.