我有一个php脚本,我通过命令行运行,如
php file.php
在该文件中我有一个类似
的打印声明print "<br>Saved the url: {$url} to :{$destination}";
我认为br会把它比另一个低1但是当我运行脚本时我会得到这种格式很难阅读
<br>Saved the url: http://example.com/a.mp3 to :/usr/recordings/3e/1555141317-2349577.mp3<br>Saved the url: http://example.com/b.mp3 to :/usr/recordings
所以在控制台中很难读取格式。有没有办法重构我的打印以获得像这样的输出
Saved the url: http://example.com/a.mp3 to :/usr/recordings/3e/1555141317-dadfdasffa.mp3
Saved the url: http://example.com/b.mp3 to :/usr/recordings/3c/1555141317-fddfd.mp3
Saved the url: http://example.com/c.mp3 to :/usr/recordings/3f/1555141317-ffdfd.mp3
答案 0 :(得分:5)
使用换行符代替br。
print "\nSaved the url: {$url} to :{$destination}";
如果你想要使用html输出,你可以检查你正在运行的sapi:
echo PHP_SAPI == 'cli' ? PHP_EOL : '<br>', "Saved the url: {$url} to :{$destination}";
答案 1 :(得分:0)
print "Saved the url: {$url} to :{$destination}\n";
答案 2 :(得分:0)
你试过\ n \ r或\ n?
是为了HTML。控制台不同。