简体   繁体   中英

How to add newline in shell_exec php?

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.

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

将相当于您的控制台命令

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM