Add variable at end of URL - PHP

I want to add the $ name variable to the URL http://google.com/script.php so that I can call this variable in another script.

How to change the following code without these syntax errors?

Thank.

Codes:

$name = $_GET['smsname'];
$call = $client->account->calls->create('+103632', $number,                                             
        'http://google.com/script.php'
    );
+5
source share
2 answers

Add this:

$name = $_GET['smsname'];
$call = $client->account->calls->create('+103632', $number,                                             
        'http://google.com/script.php?name='.$name
    );

And on the next page you can get it with $_GET['name']

+5
source

Just connect it with .

$var1 = 'text'; $var2 = 'text2';

Concatenation = $var1.$var2;

In your case.

$name = $_GET['smsname'];
$call = $client->account->calls->create('+103632', $number,                                             
        'http://google.com/script.php?name='.$name;
    );

But you have to check $namefor values, for example, if it is empty or not. Because your code will only work if script.php?name=it matters, but if it is not, then you should be prepared to do something. eg:

ex: $name = isset($_GET['smsname']) ? $_GET['smsname'] : 0;

, script.php?name= - , $name else $name 0

: 0; 0 $_GET['smsname'] . , .

+3

All Articles