Getting Started with PHP: Define using _php Tutorials

Source: Internet
Author: User
Tags define function getting started with php

PHP defines several constants in advance and provides a mechanism to define them at run time. Constants and variables are basically the same, and the difference is that constants must be defined with the Define function, which, once defined, cannot be redefined.

Pre-defined constants in PHP:

__file__

The file name of the script currently being processed. If used in a contained file, then its value is the contained file, not the file name that contains it.

__line__

The current number of rows in the file being processed.

Php_version

Represents the current version of the PHP processor, such as: 3.0.8-dev.

Php_os

The name of the operating system on which the PHP processor is located, such as: Linux.

TRUE

Truth

FALSE

False value

You can define more constants with the Define function.

For example, define constants:

Define ("CONSTANT", "Hello World");
Echo CONSTANT; Outputs "Hello world."
?>

Examples of using __file__ and __line__

function Report_error ($file, $line, $message) {
echo "An error occured in $file on line $line: $message.";
}
Report_error (__file__,__line__, "Something went wrong!");
?>

http://www.bkjia.com/PHPjc/531668.html www.bkjia.com true http://www.bkjia.com/PHPjc/531668.html techarticle PHP defines several constants in advance and provides a mechanism to define them at run time. Constants and variables are basically the same, and the difference is that constants must be defined with the Define function, a constant ...

  • Related Article

    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.