public_path() returning results with backslash instead of forward slash

折月煮酒 提交于 2021-01-27 13:12:21

问题


I am writing,

<?php echo public_path();?>

It returns results with backlashes instead of forward slashes. I expected forward slashes.


回答1:


public_path() uses DIRECTORY_SEPARATOR which depends on your OS. To change it to backslashes, you can use str_replace():

str_replace('\\', '/', public_path())

Update

For loading assets, use the assets() helper.



来源:https://stackoverflow.com/questions/48289384/public-path-returning-results-with-backslash-instead-of-forward-slash

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!