Home  >  Article  >  Backend Development  >  PHP define函数的使用说明_php技巧

PHP define函数的使用说明_php技巧

WBOY
WBOYOriginal
2016-05-17 09:35:26965browse

PHP中预先定义好的常量:

__FILE__

当前正在处理的脚本文件名。如果使用在一个被包含的文件中,那么它的值就是这个被包含的文件,而不是包含它的文件名。

__LINE__

正在处理的文件的当前行数。

PHP_VERSION

表示PHP处理器的当前版本,如:'3.0.8-dev'。

PHP_OS

PHP处理器所在的操作系统名字,如:'Linux'。

TRUE

真值

FALSE

假值

可以用DEFINE函数定义更多的常量。

如,定义常量:

<?php
define("CONSTANT", "Hello world.");
echo CONSTANT; // outputs "Hello world."
?>
用 __FILE__ 和 __LINE__ 的举例

<?php
function report_error($file, $line, $message) {
echo "An error occured in $file on line $line: $message.";
}
report_error(__FILE__,__LINE__, "Something went wrong!");
?>

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn