「PHP」defineで定数を使用するサンプル

2021年7月21日

書式
define(定数名, xxx);
サンプルコード

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<!DOCTYPE html>
<html>
<body>
<?php
// 大文字、小文字を区別する定数名
define("MSG", "test123");
define("msg", "test456");
echo MSG;
echo "<br/>";
echo msg;
?>
</body>
</html>
<!DOCTYPE html> <html> <body> <?php // 大文字、小文字を区別する定数名 define("MSG", "test123"); define("msg", "test456"); echo MSG; echo "<br/>"; echo msg; ?> </body> </html>
<!DOCTYPE html>
<html>
<body>

<?php
// 大文字、小文字を区別する定数名
define("MSG", "test123");
define("msg", "test456");
echo MSG;
echo "<br/>";
echo msg;
?> 

</body>
</html>

 

PHP

Posted by arkgame