In terminal how to pass a string as param that contains whitespace . It actually skips the part coming after whitespace and only takes the first word .
$word = 'soccer ball'
shell_exec('casperjs test.js --word='.$word);
So how can I escape the whitespace it only runs this command
casperjs test.js --word=soccer
For cases like the one you describe (there are other special characters next to space in shell), PHP has the
escapeshellargfunction:I takes care to preserve the value of
$wordas one argument:See as well: