PHP通过命令行传递的参数被截断

I am using PHP's shell_exec() to execute a program via a commandline, passing it an URL as the parameter.

Problem: The program seem to receive only a truncated version of the parameter. PHP passes the parameter

http://www.mysite.com/Men/T-Shirts-Vests/Cat/pgecategory.aspx?cid=7616&parentID=-1&pge=0&pgeSize=200&sort=1

but the program receives it as

http://www.mysite.com/Men/T-Shirts-Vests/Cat/pgecategory.aspx?cid=7616

How can I prevent it from getting truncated after the &?

PHP

    $url = 'http://www.mysite.com/Men/T-Shirts-Vests/Cat/pgecategory.aspx?cid=7616&parentID=-1&pge=0&pgeSize=200&sort=1';
    $script = path('base')."application/phantomjs/httpget.js";
    $output = shell_exec("phantomjs $script $url");

httpget.js

// Get URL from command line parameter
var system = require('system');
var url = system.args[1];
console.log(url);

Output

http://www.mysite.com/Men/T-Shirts-Vests/Cat/pgecategory.aspx?cid=7616

Use escapeshellarg

$url = escapeshellarg($url);

Quote your string:

$url = 'http://www.mysite.com/Men/T-Shirts-Vests/Cat/pgecategory.aspx?cid=7616&parentID=-1&pge=0&pgeSize=200&sort=1';
$script = path('base')."application/phantomjs/httpget.js";
$output = shell_exec("phantomjs $script \"$url\"");

For example, consider the following:

~ $ echo foo&bar
[1] 25361
foo
-bash: bar: command not found
[1]+  Done                    echo foo
~ $

vs

~ $ echo "foo&bar"
foo&bar
~ $