简体   繁体   中英

How to concatenate variable and string in laravel

我想将 select_teacherActivity 与变量 $week_no 和变量 $activity 连接为一个词

 $Activity->description = $request->input('select_teacherActivity".$week_no.".$activity');

if you want get a string you should use concat operation '.' 'select_teacherActivity".$week_no . $activity; this should work if $week_no and $activity sting or there have implemented toString magic method.

There are multiple syntax errors in the code shared:

All opening quotes should close with the corresponding type of quote:

'select_teacherActivity" //Wrong
'select_teacherActivity' //Right
.". //Wrong
."".//Right (but unnecessary) 

There is also have a stray ' at the end. Full code:

$Activity->description = $request->input('select_teacherActivity'.$week_no.$activity);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM