Welcome to the Treehouse Community
Looking to learn something new?
Just a quick question as I'm not 100% sure if the follow PHP method is OK to import a stylesheet as I'm just starting out with PHP and still not completely familiar with this sort of thing.
Here's the code I'm currently using:
<link href="<?php echo $SERVER['SERVER NAME']; ?>css/style.css" rel="stylesheet">
I want to be sure that this is an OK method and that is not some old world way of doing things, but I am sure open to any suggestions on how this could be done better, maybe Hampton Paulk could give his views.
Thanking you in advance,
Aaron Graham18,033 Points
I use it in my code and it seems to work fine. This works especially well when you develop on a server under one url (for example development.example.com), and deploy to another url (example.com). One thing to watch out for is, if you are running under an Apache virtual host, this value comes from the "ServerName" attribute in your virtual host configuration. Make sure that is set correctly. Also, I should point out that it is
'SERVER_NAME' with an underscore.
EDIT: I also just noticed that you have
$SERVER instead of
Thanks guys, that was a real help. :)