问题
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