简体   繁体   中英

Add new line to dynamically created js file

I am using PHP to concatenate several Javascript files into one. I need to add new lines beforeeach part is added and have tried '\\n' but this throws an unknown character error. What is the correct character to indicate a new line?

file_put_contents($JSfile," /n ");


$jspart = file_get_contents($myfile);
file_put_contents($JSfile,'  '. $jspart  , FILE_APPEND);

您可以使用预定义的PHP常量PHP_EOL添加正确的“行尾”符号:

file_put_contents($JSfile, PHP_EOL);

Use only following in your Codes

$jspart = file_get_contents($myfile);
file_put_contents($JSfile, $jspart . "\n", FILE_APPEND);

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