How to add newline in shell_exec php?

Viewed 30

I want to execute a node.js file via php. The thing that I want to achieve in PHP is this

C:proj> node main.js text="This is some text.
>> some more text in next line"

My php script

shell_exec('node C:\proj\main.js text="This is some text. \n some more text in next line"');

But in my main.js file, I'm only getting

text = this is some text.

rest of the string is getting removed. Could anyone help please?

Things I've tried

  1. \n
  2. `n
  3. >>
  4. PHP_EOL
  5. ^
  6. ^\n

but no luck!

I hope my question is clear. Please feel free to ask for more details.

1 Answers
shell_exec("node C:\proj\main.js text=\"This is some text.\n>> some more text in next line\"");

will equivalent of your console command

Related