$username = $this->username ?: 'someone';
$email = $this->email ?: Yii::$app->params['adminEmail'];
$password = Yii::$app->getSecurity()->generatePasswordHash(
$this->password ?: 'xx'
);
$table = User::tableName();
$auth_key = Yii::$app->security->generateRandomString();
$status = User::STATUS_ACTIVE;
$timestamp = time();
$god = 1;
$words = "in the ${table} has a record which contains some value : ";
$words .= "'${username}', '${email}', '${password}', '${auth_key}', '${status}','${timestamp}', '${god}', '${timestamp}', '${god}' ";
上面的 word 怎样拼凑才能优雅些?
sprintf
是个不错的方案不过看你的代码感觉就是像把各种变量都打出来调试用,那么有个神器
get_defined_vars
,变量名变量值都有了你值得拥有