我有一个PHP脚本,我通过命令行运行,如
php file.php
Run Code Online (Sandbox Code Playgroud)
在那个文件中,我有一个类似的打印声明
print "<br>Saved the url: {$url} to :{$destination}";
Run Code Online (Sandbox Code Playgroud)
我认为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
Run Code Online (Sandbox Code Playgroud)
所以在控制台中很难读取格式.有没有办法重构我的打印,以获得这样的输出
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
Run Code Online (Sandbox Code Playgroud)
使用换行符代替br.
print "\nSaved the url: {$url} to :{$destination}";
Run Code Online (Sandbox Code Playgroud)
如果你想要使用html输出,你可以检查你正在运行的sapi:
echo PHP_SAPI == 'cli' ? PHP_EOL : '<br>', "Saved the url: {$url} to :{$destination}";
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
544 次 |
最近记录: |