国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

PHP development basic tutorial magic constants

Overview

PHP provides a large number of predefined constants to any script it runs.

However, many constants are defined by different extension libraries and will only appear when these extension libraries are loaded, or after dynamic loading, or have been included during compilation.

1. There are eight magic constants whose values ??change as their positions in the code change

For example, the value of __LINE__ It depends on which line it is in the script. These special constants are not case-sensitive

See the following table for details:

17.png

You can’t learn by just looking at it. Let’s see the output results from examples. Bar
Example: The code is as follows

<?php
//__LINE__  文件中當(dāng)前行號(hào)__________________________
echo '這是第 “ '  . __LINE__ . ' ” 行';
echo "<hr/>";
//__FILE__  文件的完整路徑和文件名__________________
echo '該文件位于 “ '  . __FILE__ . ' ” ';
echo "<hr/>";
//__DIR__  文件所在的目錄___________________________
echo '該文件位于 “ '  . __DIR__ . ' ” ';
echo "<hr/>";
//__LINE__  文件中當(dāng)前行號(hào)__________________________
echo '這是第 “ '  . __LINE__ . ' ” 行';
echo "<hr/>";
//__FUNCTION__  函數(shù)名稱(chēng)____________________________
function test() {
    echo  '函數(shù)名為:' . __FUNCTION__ ;
}
test();
echo "<hr/>";
//__CLASS__  類(lèi)的名稱(chēng)_______________________________
class c {
    function _print() {
        echo '類(lèi)名為:'  . __CLASS__ . "<br>";
        echo  '函數(shù)名為:' . __FUNCTION__ ;
    }
}
$t = new c();
$t->_print();
echo "<hr/>";
?>

Note: Please understand the following magic constants first, and there will be details in subsequent chapters

Note: Pay attention to the php version problem. Inappropriate versions will report errors


Continuing Learning
||
<?php //__LINE__ 文件中當(dāng)前行號(hào)__________________________ echo '這是第 “ ' . __LINE__ . ' ” 行'; echo "<hr/>"; //__FILE__ 文件的完整路徑和文件名__________________ echo '該文件位于 “ ' . __FILE__ . ' ” '; echo "<hr/>"; //__DIR__ 文件所在的目錄___________________________ echo '該文件位于 “ ' . __DIR__ . ' ” '; echo "<hr/>"; //__LINE__ 文件中當(dāng)前行號(hào)__________________________ echo '這是第 “ ' . __LINE__ . ' ” 行'; echo "<hr/>"; //__FUNCTION__ 函數(shù)名稱(chēng)____________________________ function test() { echo '函數(shù)名為:' . __FUNCTION__ ; } test(); echo "<hr/>"; //__CLASS__ 類(lèi)的名稱(chēng)_______________________________ class c { function _print() { echo '類(lèi)名為:' . __CLASS__ . "<br>"; echo '函數(shù)名為:' . __FUNCTION__ ; } } $t = new c(); $t->_print(); echo "<hr/>"; ?>
submitReset Code