DIR vs URI when defining a path to a file

When you include something, you use the file path because it’s a local file and you’re reading into the environment right here and now and using that code.

When you “enqueue” something, you’re not reading the file in, you’re sending the URL of the file to a system that puts that URL in the resulting output webpage, for the viewer’s browser to then load and read.

You use a file path when the PHP code is manipulating the file. You use a URL when the browser needs to see that URL and retrieve the file itself.

Leave a Comment