tim@getdim Posted May 7, 2012 Share Posted May 7, 2012 I know basically nothing about PHP but i have a few websites i manage that are built with PHP. I plan to learn PHP but for the time being learning Javascript has a wider range of usability for me. That being said, Im trying to link to an XML sitemap using php. in html i would use <link href="sitemap.xml" /> how can i do this in PHP? I have searched google and such for how to do this but was unable to find an explanation that i could understand as relating to my need. Quote Link to comment https://forums.phpfreaks.com/topic/262226-how-to-link-external-files-with-php/ Share on other sites More sharing options...
Jessica Posted May 7, 2012 Share Posted May 7, 2012 I hope you wouldn't do that, as that's not valid html. The HTML for a link is <a href="url.etx">Link Text</a> . I don't know XML so I don't know if you're accidentally doing XML and calling it HTML. That said, PHP can print HTML, or you can include raw HTML in php. You can't find out how to do it because you're asking the wrong question. <?php echo '<b>This is bold text</b>'; ?> or <?php //Your php code here ?> <b>This is my bold html</b> <?php //more php in here ?> Quote Link to comment https://forums.phpfreaks.com/topic/262226-how-to-link-external-files-with-php/#findComment-1343800 Share on other sites More sharing options...
tim@getdim Posted May 7, 2012 Author Share Posted May 7, 2012 Actually its perfectly valid HTML - its the same way you link a stylesheet. It works perfectly fine in every other site ive used it in. I actually just figured out what my problem was. i had tried to use raw html outside the <?php tag but it was causing error messages when i uploaded the file. turns out i had the wrong file. the site in question is using the MODx CMS which i am not familiar with - but after searching through the file structure for a while i was able to find the file that was generating the html for the index page. once i put in my html code there right underneath the stylesheet links, it worked perfectly fine. Thanks for your time, though. Sorry it turned out to be unneeded. Quote Link to comment https://forums.phpfreaks.com/topic/262226-how-to-link-external-files-with-php/#findComment-1343809 Share on other sites More sharing options...
Jessica Posted May 7, 2012 Share Posted May 7, 2012 The way it was worded it sounded like a link in the body, not linking a document in the head. I see what you're talking about now. Everything I've read says <link> is not heavily supported for anything other than stylesheets, but if it is working for you then go ahead. Quote Link to comment https://forums.phpfreaks.com/topic/262226-how-to-link-external-files-with-php/#findComment-1343819 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.