LoginSignup
3
0

More than 5 years have passed since last update.

PHPの定数って日本語使えるんだね

Posted at

PHP の定数について

定数 - PHP マニュアル > 言語リファレンス

定数の名前は、PHP のラベルと同じ規則に従います。有効な定数の名前は、 文字またはアンダースコアで始まり、任意の数の文字、数字、 アンダースコアが後に続きます。正規表現で示すと次のようになります。 [a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*

なるほど定数に使えるのは英数字だけなのか :whale2:

とみせかけて

定数.php
<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(-1);


define('こんにちは', 'Hello');
echo こんにちは . PHP_EOL ;


const さようなら = 'Bye';
echo さようなら . PHP_EOL ;
出力結果
Hello
Bye

わぁい!:whale2:

参考と注釈

3
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
0