簡體   English   中英

如何使用 php 以正確的格式發送短信?

[英]How to send sms in proper format using php?

在這段代碼中,我使用短信網關向客戶端發送消息。 現在,短信發送成功,但格式看起來很簡單:

This is a remainder about the title by the 2019-11-11 hello

看起來很簡單我想顯示的消息應該是這樣的:

This is a remainder about by 2019-11-11關於the title的剩余部分hello Line 應該在abouttitledatemessage之后中斷

那么我該怎么做呢? 請幫我。

謝謝你

$message = "This is a reminder about the ".$this->input->post("title")." by the ".date("Y-m-d", strtotime($this->input->post("date")))." ".strip_tags(html_entity_decode($this->input->post("notice")))."";
$requestParams = array(
    'user' => '**********',
    'pass' => '**********',
    'sender' => '*******',
    'phone' => trim(json_encode($student_phone, JSON_NUMERIC_CHECK),'[]'),
    'text' => $message,
    'priority' => 'ndnd',
    'stype' => 'normal'
);
$apiUrl = "http://bhashsms.com/api/sendmsg.php?";
foreach($requestParams as $key => $val){
    $apiUrl .= $key.'='.urlencode($val).'&';
}

$apiUrl = rtrim($apiUrl, "&");
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $apiUrl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec($ch);
curl_close($ch);
$return = json_encode($result);

嘗試使用“新行”字符\n 像這樣將它插入到字符串中:

$message = "This is a reminder about \n the ".$this->input->post("title")."\n by the ".date("Y-m-d", strtotime($this->input->post("date")))."\n".strip_tags(html_entity_decode($this->input->post("notice")))."";

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM