簡體   English   中英

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

[英]How to add newline in shell_exec php?

我想通過 php 執行一個 node.js 文件。 我想在 PHP 中實現的是這個

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

我的 php 腳本

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

但在我的 main.js 文件中,我只得到

text = this is some text.

字符串的其余部分被刪除。 有人可以幫忙嗎?

我嘗試過的事情

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

但沒有運氣!

我希望我的問題很清楚。 請隨時詢問更多詳細信息。

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