Ok so I have an xml and xsl file. Works great.
How would I make it so users would see my home page as home.php instead of home.xml?
I need to add PHP to my site content, let's say I need to use some variables or better yet connect to a database to display some info, how would I go about doing that?
Adding PHP to my xml file
Moderator: General Moderators
- jaoudestudios
- DevNet Resident
- Posts: 1483
- Joined: Wed Jun 18, 2008 8:32 am
- Location: Surrey
Re: Adding PHP to my xml file
Have your xml in a .php file and a xml header with the php function header();
i.e.
Using the code above will parse your code as xml, this will allow you to do php stuff around your xml code.
i.e.
Code: Select all
header("Content-type:text/xml"); // check the exact type!
Re: Adding PHP to my xml file
Doesn't seem to be working. The page is blank. Should I be putting echos everywhere?
test.php
test.php
Code: Select all
<?php header("Content-type:text/xml"); ?>
<?xml version="1.0" encoding="ISO-8859-1"?>
<note>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>- jaoudestudios
- DevNet Resident
- Posts: 1483
- Joined: Wed Jun 18, 2008 8:32 am
- Location: Surrey
Re: Adding PHP to my xml file
Yep you will need to echo everything out