【发布时间】:2015-09-20 23:27:55
【问题描述】:
我有以下代码。
function up() {
$runafterupdate = [];
Schema::connection('exitproducts')->create('exitcontrol_carmanager_manager', function($table)
{
$table->engine = 'InnoDB';
$table->increments('id');
$table->string('code');
$runafterupdate['code'] = true;
$table->timestamps();
});
}
if(isset($runafterupdate['code'])) {
echo "it worked!";
}
}
我已经习惯了 JavaScript,您可以在其中更改父范围的值,但显然 php 遵循不同的规则。 我试过阅读http://php.net/manual/en/language.variables.scope.php,但我真的不想使用全局变量。
有没有办法用 php 改变父作用域中的变量,或者在这种情况下我唯一的手段是全局变量吗?
【问题讨论】: