Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Plus signs ("+") disappears

Tags:

html

php

I am sending sms to cellphones using PHP and an API key provided by my sms service provider.

The sms that I send reaches the target cellphone perfectly but the problem is when I have a "+" sign in my message the "+" do not appear in the cellphone. This is probably happening because the "+" sign is basically used for indicating a space.

When I run the api my code looks like following:

$msg="A+";
$x= file_get_contents("http://someurl...&msg=$msg");

Could you please tell me what to do to make the "+" appear in cellphones.

Thanks

like image 795
black_belt Avatar asked Jan 27 '13 16:01

black_belt


3 Answers

You'll need to look into using the function urlencode.

$x = file_get_contents("http://someurl...&msg=" . urlencode($msg));
like image 89
Wayne Whitty Avatar answered Nov 13 '22 08:11

Wayne Whitty


Try to use urlencode

$msg = urlencode("A+");

As php manual says:

This function is convenient when encoding a string to be used in a query part of a URL, as a convenient way to pass variables to the next page.

like image 23
Davide Berra Avatar answered Nov 13 '22 09:11

Davide Berra


Use urlencode...

$msg="A+";
$msg = urlencode($msg);
$x= file_get_contents("http://someurl...&msg=$msg");
like image 1
ATOzTOA Avatar answered Nov 13 '22 08:11

ATOzTOA