Search code examples
phplaravel-4twiliotwilio-php

New line not recognized by Twilio in PHP


Using PHP/Laravel.
And the latest Twilio library 5.16.2

Followed this - https://support.twilio.com/hc/en-us/articles/223181468-How-do-I-add-a-line-break-in-my-SMS-message-

And none of these work, they are sent as it is:

  • %0a
  • \n
  • %0D%0A

$textMessageToSend = $textMessageToSend . ' %0a ' . $emailLinkOfContent;

What am I missing ?


Solution

  • The problem is with the single quoted string use Double quotes to solve the issue,

    $textMessageToSend = $textMessageToSend . "%0a" . $emailLinkOfContent;
    

    make sure $textMessageToSend and $emailLinkOfContent are both strings assigned with double quotes if initialisation is hard-coded.