What i need to do is this
if (isset($message))
{
$message = $message . $new_message;
}
else
{
$message = $new_message;
}
Is there a simple way to do this with no if ?
I tried
$message .= $new_message;
But when $message is not set, i get Severity Notice Undefined property
The reason i need to do this is i show errors/messages with $message in views and if i simply do $message = $new_message; older errors/messages are gone.
Any help/method is appreciated.
You can use ternary operator:
$message = isset($message) ? $message.$new_message : $new_message;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With