猿问

怎样拼凑更易读的字符串?

$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="inthe${table}hasarecordwhichcontainssomevalue:";
$words.="'${username}','${email}','${password}','${auth_key}','${status}','${timestamp}','${god}','${timestamp}','${god}'";
上面的word怎样拼凑才能优雅些?
慕尼黑5688855
浏览 272回答 2
2回答

呼啦一阵风

sprintf是个不错的方案不过看你的代码感觉就是像把各种变量都打出来调试用,那么有个神器get_defined_vars,变量名变量值都有了你值得拥有
随时随地看视频慕课网APP

相关分类

JavaScript
我要回答