Using "SELECT" query a string fetched from database which included variable name, "Dear $customer_name " in that page $customer_name='John Denie' but in echo it prints "Dear $customer_name" instead of "Dear John Denie"
/// in brief codding just to clear idea ///
$customer_name='John Denie';
"SELECT SMS_text From table" //SMS_text value in database is Dear $customer_name
$sms_body=$row["SMS_text"];
echo $sms_body
Now this $sms_body echo Dear $customer_name and I want it should print Dear John Denie as per code $customer_name keep changes here I assigned static value forexample.
I tried {} trim function and other methods but nothing for me. any ideas?
CodePudding user response:
if your sms_text == 'Dear $customer_name ...' you should just add row after
$sms_body=$row["SMS_text"];
and before
echo $sms_body:
you should add this row:
$sms_body= str_replace('$customer_name',$customer_name,$sms_body);
Perhaps your expectations are based on the idea that,
echo $sms_body; is equivalent to echo "Dear $customer_name ...";, in fact, you have echo $sms_body; is equivalent to echo 'Dear $customer_name ...';