Created
June 6, 2020 09:15
-
-
Save huuyafwww/b044bfa3463011ecf3c563fcb9184532 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<pre> | |
<?php | |
$define_names = [ | |
"A" => "a", | |
"B" => "b", | |
"C" => "c", | |
"D" => "d", | |
"E" => "e", | |
]; | |
foreach( | |
$define_names | |
as | |
$define_name | |
=> | |
$var | |
){ | |
define( | |
$define_name, | |
$var | |
); | |
} | |
print_r( | |
get_defined_constants() | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
動的な定義をdefineで可能。
例として、foreachで連想配列を舐めながら動的定義を行っている