php - How to escape ampersand symbol -


this question has answer here:

i want escape ampersand symbol. because, assume parameter.. want pass below message java web service parameter.. ampersand symbol cut message.. please help

my php code:

$message ="hi $names \r\n";  $message.="welcome home 2 office rider network. activate account \r\n";  $message.="please verify email using below url \r\n\n";  $message.="http://localhost/h2orn/php/verify.php?email=$emails&hash=$hash \n\n\n ";     $message.="thanks interest , support h2orn. kindly reach out \r\n";     $message.="'care@h2orn.in' queries relating h2orn operations.\r\n\n\n";     $message.="thanks\r\n";     $message.="support team\r\n\n\n";  $message.="this automated email message. please not reply email.\r\n \n\n";  $url = "http://localhost:8084/mail/webresources/emailtest"; $mail = "toaddress=" . $emails . "&emailbody=" . $message ; $ch  = curl_init($url); 

thanks advance,

you don't just want encode ampersands, want uri-encode of values. urlencode function.

$mail = "toaddress=" . urlencode($emails) . "&emailbody=" . urlencode($message) ; //                     ^^^^^^^^^                            ^^^^^^^^^ 

Comments