Space in php

I am integrating sms api with my form but when I submit the I get like this sms: MOBILE-NUMBERmessage. (+10000000000this is my message)
But I want space between MOBILE-NUMBER and message. Like; (+100000000 message.

I too much try but it will done something error or not working…

What I do ?

PHP

<?php
$mobileNumber = "0000000000";
if(isset($_POST['submit']))
{
$message = $_POST['textbox1'] . \n $_POST['textbox2'];
$authKey = "abcdefghijklmnopqrstuvwxyz";
$senderId = "ABCDEF";
$route = "4";
$postData = array(
    'authkey' => $authKey,
    'mobiles' => $mobileNumber,
    'message' => $message,
    'sender' => $senderId,
    'route' => $route,
    'country'=>'0'
);
$url="https://website.com/api/sendhttp.php";
$ch = curl_init();
    curl_setopt_array($ch, array(
    CURLOPT_URL => $url,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_POST => true,
    CURLOPT_POSTFIELDS => $postData
));
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
$output = curl_exec($ch);
 if(curl_errno($ch))
{
    echo 'error:' . curl_error($ch);
}
curl_close($ch);
echo '
 <h3>Success!</h3>
    <p>Red often indicates a dangerous or negative situation.</p>';
}
?>

HTML


<!DOCTYPE html>
<html>
        <head>
                <meta charset="utf-8">
            
                                        <meta http-equiv="content-type" content="text/html; charset=utf-8">
                </head><body><input type="tel" name="mobile" value="0000000000"/><br><input type text="text"name="message" /><br><input type="submit" name="submit" value="submit"/></body></html>

I would appreciate.please help and tell me how I mention after MOBILE-NUMBER.

** This is message)

I too much try but it will done something error or not working…
What I do ?

PHP

<?php
$mobileNumber = "0000000000";
if(isset($_POST['submit']))
{
$message = $_POST['mobile'] . \n $_POST['message'];
$authKey = "abcdefghijklmnopqrstuvwxyz";
$senderId = "ABCDEF";
$route = "4";
$postData = array(
    'authkey' => $authKey,
    'mobiles' => $mobileNumber,
    'message' => $message,
    'sender' => $senderId,
    'route' => $route,
    'country'=>'0'
);
$url="https://website.com/api/sendhttp.php";
$ch = curl_init();
    curl_setopt_array($ch, array(
    CURLOPT_URL => $url,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_POST => true,
    CURLOPT_POSTFIELDS => $postData
));
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
$output = curl_exec($ch);
 if(curl_errno($ch))
{
    echo 'error:' . curl_error($ch);
}
curl_close($ch);
echo '
 <h3>Success!</h3>
    <p>Red often indicates a dangerous or negative situation.</p>';
}
?>

HTML


<!DOCTYPE html>
<html>
        <head>
                <meta charset="utf-8">
            
                                        <meta http-equiv="content-type" content="text/html; charset=utf-8">
                </head><body><input type="tel" name="mobile" value="0000000000"/><br><input type text="text"name="message" /><br><input type="submit" name="submit" value="submit"/></body></html>

I would appreciate.please help and tell me how I mention after MOBILE-NUMBER.

Try this instead of what you have:

$message = $_POST['mobile'] . ' ' . $_POST['message'];

The above does a space.
If you want a new line use this:

$message = $_POST['mobile'] . "\n" . $_POST['message'];

Note that the double-quotes are important so it evaluates to newline and not a string literal.

@phpRob THANK YOU! THANK YOU SO MUCH …

YOU DONT KNOW , I SPENT 10 DAYS TO CORRECT IT…BUT YOU NOW HELP ME …THANK YOU THANK YOU SO MUCH…:heart_eyes: :kissing_heart:

But we add space ?

I’m not sure what you are doing. Plus you are soliciting help everywhere with everything it seems like. Please invest some time in reading a good book. But depending on context…
if in php: “\n” for new line; ’ ’ for space
if in html (or html output): &nbsp for space (just type it in your html and is will generate space);
for newline.
&nbsp&nbsp&nbsp&nbsp <–that is four spaces in html on one line and don’t use quotes unless you are using php to echo out. Good luck.

1 Like

You’re missing the end semicolon.

&nbsp;

1 Like

for newline: (the html break tag) <br />

correct &nbsp; example: &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (5 spaces)

1 Like

I think just typing a space is best. &nbsp; is a not breaking space.

Personally I don’t like to see chained &nbsp;s like that, is feels hacky, like people who don’t get css and use that kind of thing instead of margins or padding.

1 Like

Browsers automatically combine multiple literal spaces into one so a hack is needed in the case of achieving multiple spaces. I’d be interested in a way to avoid such a hack.

This:-

1 Like

Would you prefer to attach some css to the document to achieve three spaces in a row on a single line of text? Not efficient. There are indeed gaps between what html allows and what css requires.

I generally use css on all my html documents anyway. I find they look a little plain without any, so yes, if such a need were to ever arise. I don’t recall ever needing multiple spaces in html text.

Problem has fixed. Thanks for responding…

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.