简体   繁体   English

如何在 shell_exec php 中添加换行符?

[英]How to add newline in shell_exec php?

I want to execute a node.js file via php.我想通过 php 执行一个 node.js 文件。 The thing that I want to achieve in PHP is this我想在 PHP 中实现的是这个

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

My php script我的 php 脚本

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但在我的 main.js 文件中,我只得到

text = this is some text.

rest of the string is getting removed.字符串的其余部分被删除。 Could anyone help please?有人可以帮忙吗?

Things I've tried我尝试过的事情

  1. \n \n
  2. `n `n
  3. >> >>
  4. PHP_EOL PHP_EOL
  5. ^ ^
  6. ^\n ^\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\"");

将相当于您的控制台命令

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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