在URL末尾添加变量 - PHP

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

How do I modify the following code without having those syntax errors?

Thanks.

Codes:

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

Just concatenate it using .

$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 should validate $name for values, as in if it is empty or not. Because, that code of yours will only works if if script.php?name= has a value, but if it is not, then you should be prepared to do something instead. like this:

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

The above code pretty much says, if script.php?name= is set to some value, then assign it to $name else $name should be 0

The : 0; part, is there to set a value of 0 IF nothing is set or if $_GET['smsname'] is empty. You can add anything you like there

Append it like so

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

And in the next page you can get it using $_GET['name']