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

PHP Beginner's Guide to Magic Variables

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

The current line number in the file

<?php
	header("Content-type: text/html; charset=utf-8");//設(shè)置編碼 
	echo '這是第 “ '  . __LINE__ . ' ” 行';    //查看第幾行
?>

2. __FILE__


The full path and file name of the file. If used within an included file, returns the name of the included file.

Since PHP 4.0.2, __FILE__ always contains an absolute path (or the resolved absolute path if it is a symbolic link), while versions before that sometimes contained a relative path

<?php
	header("Content-type: text/html; charset=utf-8");//設(shè)置編碼 
	echo '該文件位于 " '  . __FILE__ . ' " ';	//查看路徑
?>	


3. __DIR__


The directory where the file is located. If used within an included file, returns the directory where the included file is located.

It is equivalent to dirname(__FILE__). Directory names do not include the trailing slash unless they are the root directory. (New in PHP 5.3.0)

<?php
	header("Content-type: text/html; charset=utf-8");//設(shè)置編碼 
	echo '該文件位于 " '  . __DIR__ . ' " ';
?>


##4.

__FUNCTION__

<?php
    function test() {
    	echo  '函數(shù)名為:' . __FUNCTION__ ;
    }
    test();
?>

5.

__CLASS__


The name of the class (newly added in PHP 4.3.0). Since PHP 5 this constant returns the name of the class when it was defined (case sensitive).

In PHP 4 this value is always lowercase. The class name includes the scope in which it is declared (e.g. Foo\Bar). Note that since PHP 5.4 __CLASS__ also works for traits. When used in a trait method, __CLASS__ is the name of the class that calls the trait method

<?php
    	class test {
		function _print() {
			echo '類名為:'  . __CLASS__ . "<br>";
			echo  '函數(shù)名為:' . __FUNCTION__ ;
		}
	}
	$t = new test();
	$t->_print();
?>


6.

__METHOD__


Returns the name of the method when it was defined (case sensitive)

	<?php
	    function test() {
		echo  '函數(shù)名為:' . __METHOD__ ;
	    }
	    test();
	?>


Continuing Learning
||
<?php header("Content-type: text/html; charset=utf-8");//設(shè)置編碼 echo '這是第 “ ' . __LINE__ . ' ” 行'; //查看第幾行 ?>
submitReset Code