PHP Basic functions

Source: Internet
Author: User
Tags php source code
Introduction: This is the PHP basic function of the detailed page, introduced and PHP, related knowledge, skills, experience, and some PHP source code and so on.

class= ' pingjiaf ' frameborder= ' 0 ' src= ' http://biancheng.dnbcw.info/pingjia.php?id=335085 ' scrolling= ' no ' > Define Constants
Define (' APPCONFIG ', ' placonfig ');
GET constant
ECHO constant (' APPCONFIG '). " \ n ";
Constants cannot be defined two times

Initialize the value of a variable
Ini_set (' display_errors ', 1);
Gets the value of the variable.
echo ini_get (' display_errors '). " \ n ";


With PHP's
Ob_start ();

Introduction to related functions:
1, Flush: Flush the contents of the buffer, output.
function format: Flush ()
Description: This function is often used and is highly efficient.
2. Ob_start: Open Output buffer
function format: void Ob_start (void)
Note: When the buffer is active, all non-file header information from the PHP program is not sent, but is saved in the internal buffer. In order to output the contents of the buffer, you can use the contents of the Ob_end_flush () or flush () output buffers.
3. Ob_get_contents: Returns the contents of the internal buffer.
How to use: String ob_get_contents (void)
Description: This function returns the contents of the current buffer and returns FALSE if the output buffer is not activated.
4. Ob_get_length: Returns the length of the internal buffer.
How to use: int ob_get_length (void)
Note: This function returns the length of the current buffer, as with ob_get_contents, if the output buffer is not activated. FALSE is returned.
5. Ob_end_flush: Sends the contents of the internal buffer to the browser, and closes the output buffer.
How to use: void Ob_end_flush (void)
Description: This function sends the contents of the output buffer (if any).
6. Ob_end_clean: Delete the contents of the internal buffer and close the internal buffer
How to use: void Ob_end_clean (void)
Description: This function does not output the contents of the internal buffer but deletes it!
7. Ob_implicit_flush: Turn absolute refresh on or off
How to use: void Ob_implicit_flush ([int flag])
Description: People who have used Perl know the meaning of $|=x, this string can open/close the buffer, and the Ob_implicit_flush function is the same, the default is to close the buffer, open the absolute output, each script output is sent directly to the browser, no longer need to call flush ()


Example:

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

Output:
Hello
Cache=hello



$t 0=0;
$s 0=0;
$t 1=0;
$s 1=0;
$t 2=0;
$s 2=0;
$t 3=0;
$s 3=0;
if (Ob_get_level ()) {
$t 0=1;
$s 0=ob_get_level ();
}
Ob_start ();
if (Ob_get_level ()) {
$t 1=1;
$s 1=ob_get_level ();
}
Ob_start ();
if (Ob_get_level ()) {
$t 2=1;
$s 2=ob_get_level ();
}
Ob_start ();

if (Ob_get_level ()) {
$t 3=1;
$s 3=ob_get_level ();
}
Ob_end_flush ();
Ob_end_flush ();
Ob_end_flush ();
echo "t0=". $t 0. " \ n ";
echo "s0=". $s 0. " \ n ";
echo "t1=". $t 1. " \ n ";
echo "s1=". $s 1. " \ n ";
echo "t2=". $t 2. " \ n ";
echo "s2=". $s 2. " \ n ";
echo "t3=". $t 3. " \ n ";
echo "s3=". $s 3. " \ 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.

The function is an alias for the exit () function.
Grammar

Die (status)

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

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

If the status is an integer, this value is used as the exit state. The value of the exit status is between 0 and 254. Exit status 255 is reserved 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 about PHP basic functions

Love EE focus on Java Michael Jackson Video station JSON online tool

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.