It is possible to put If inside $message variable? code shown below :
$message = "Semangat Pagi Akang & Teteh Semua!n"
. "Nyai Iteung mengucapkan selamat ulang tahun 💬 untuk:nn"
if($getNowCuti->AllKaryawan->jenis_kelamin == 'L')
{
. "Pak" . $stringKaryawan . "nn"
} else {
. "Bu" . $stringKaryawan . "nn"
}
. "Selamat cuti juga yaa untuk:nn"
if($getNowCuti->AllKaryawan->jenis_kelamin == 'L')
{
. "Pak" . $stringKaryawan . "nn"
} else {
. "Bu" . $stringKaryawan . "nn"
}
. "Harap rekan-rekan Kabayan Group tidak memberikan tugas kepada pegawai diatas pada hari ini.";
It shows an error, how should I fixed it? Thanks guys, have a great day!
3
Answers
If you want to do this in one line, try like this.
Otherwise, the following method (answer by @Gert B.) is a nicer use case:
You cannot add a if directly inside of the build op the string, but you can append to the string inside of an if statement:
you can make it even easier to read by assigning a variable ahead since you use it twice.