user379888
user379888

Reputation:

public_path() returning results with backslash instead of forward slash

I am writing,

<?php echo public_path();?>

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

Upvotes: 6

Views: 4386

Answers (1)

Alexey Mezenin
Alexey Mezenin

Reputation: 163748

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.

Upvotes: 5

Related Questions