I want to show the single quotes within echo
$email = "[email protected]";
echo 'mail->addAddress('.$email.')';
It has to come out like this:
mail->addAddress('[email protected]');
I want to show the single quotes within echo
$email = "[email protected]";
echo 'mail->addAddress('.$email.')';
It has to come out like this:
mail->addAddress('[email protected]');
Use double quotes outside and simple inside:
$email = "[email protected]";
echo "mail->addAddress('$email');";
With the single quotes, print literals. With the doubles it prints the content and its variables.
Ex:
echo '$email'
print "$email"
echo "$email"
print "[email protected]"
You can also use the escape character as Diego says in his answer.
You can use the escape character /:
$email = "[email protected]";
echo 'mail->addAddress(\''.$email.'\')';
Or also using double quotes on the outside:
$email = "[email protected]";
echo "mail->addAddress('$email')";
Also, in this second example, you do not need to use concatenation, since PHP searches inside the chain if there are variables to print.