如何使用php将echo语句和变量值传递给url

I want pass my Default message as well as variable value in url using php. My code not working with default message.. My code here:

 $alertmsg= "Your verification code is $password 
";

 $url = "http://01.50.92.51/api/smsapi.aspx?username=xxxxxxx&password=xxxxxx&to=$mobiles&from=xxxx&message=$alertmsg";

    $ch  = curl_init($url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    $curl_scraped_page = curl_exec($ch);
    curl_close($ch);

Please anyone help me.

You can use your message variable this way

$alertmsg= "Your verification code is $password 
";
$url = "http://01.50.92.51/api/smsapi.aspx?username=xxxxxxx&password=xxxxxx&to=$mobiles&from=xxxx&message=".$alertmsg;

You can send the parameters in this way.

 $alertmsg= "Your verification code is $password 
";
 $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_POSTFIELDS, "message=" . urlencode($alertmsg));
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 300);
    $data = curl_exec($ch);
    curl_close($ch);