PHP 定数

PHPには定数という非常に便利なものがある。



<html>

<head>

<title>PHP test1</title>

</head>

<body>



<?php

print"PHPのヴァージョンは";

print PHP_VERSION;

print"です";

?>



</body></html>

HTMLタグ内にPHPソースコードは埋め込める







上のように書くと



PHPのヴァージョンは5.3.1です




とブラウザに表示される。






<html>

<head>

<title>PHP test2</title>

</head>

<body>



<?php

print"このファイル名は";

print __FILE__;←_x2x2

print"です";

?>



</body></html>



このファイル名はC:\xampp\htdocs\test2.phpです








<html>

<head>

<title>PHP test2</title>

</head>

<body>



<?php

print"行は";

print __line__;

print"行目です";

?>



</body></html>







行は9行目です