只是出于好奇是否可以做这样的事情:
$commands = [
strtolower('JUST TESTING'),
date('Y-m-d H:i:s'),
strtoupper('Done!'),
];
foreach ($commands as $command) {
$command;
}
这当然不行!有办法让它发挥作用吗?
我的具体用例是这样的:
private function dropDatabasesAndMySQLUsers(): void
{
foreach ($this->getCommands() as $command) {
$command;
}
$this->info('Done! All app Databases and MySQL users are dropped');
}
public function getCommands(): array
{
return [
\DB::statement("DROP USER IF EXISTS 'myuser'@'localhost'"),
\DB::statement("DROP DATABASE IF EXISTS manager")
// I have about 20-30 of these
];
}
喵喵时光机
慕娘9325324