Newlines not being interpreted when passed to php via the command line
- by CarbonX
I have a PHP script that I'm invoking from another shell script that sends an automated email with a message generated from the shell script. Problem is, when I send the message all the newline characters are printed into the message. How do I get them to be interpreted?
sendmail.sh:
/path/to/phpscript/sendmail.php "Some Message With Newlines\nHello World.\n"
sendmail.php:
$message = $argv[1] . "\nNewline";
$smtp->send($to, $from, $message);
The odd thing is the \n after the $argv variable is interpreted and actually prints Newline on a new line, but the newlines in the $argv variable don't, I have tried wrapping the variable in double quotes among other things but so far to no avail.