Skip to content

Instantly share code, notes, and snippets.

@huuyafwww
Created June 6, 2020 09:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save huuyafwww/b044bfa3463011ecf3c563fcb9184532 to your computer and use it in GitHub Desktop.
Save huuyafwww/b044bfa3463011ecf3c563fcb9184532 to your computer and use it in GitHub Desktop.
<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()
);
@huuyafwww
Copy link
Author

動的な定義をdefineで可能。
例として、foreachで連想配列を舐めながら動的定義を行っている

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment