Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

226
Views
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.

about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

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

about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!