How can I use php script in xhtml file?
I have short_open_tags = Off in the php.ini and I tried to use <?php ?> or <script language="php"> </script> within xhtml file (I need to use xforms), but my php code is never parsed.
Why is that?

Thanks for advice.

If I give .php extension browser doesn't display the XForms. They are only displayed when the file is .xhtml. If I change to .php, can I send any header to tell the browser that it is an .xhtml file?

We'll try to force apache to parse that file with the .xhtml extension as PHP. Put this code in an .htaccess file in the same directory as that .xhtml file:

<Files file.xhtml>
    ForceType application/x-httpd-php
</Files>

Change file.xhtml with whatever the real file name is. This should force the server to parse any PHP in there. Hopefully this won't break any compatibility with the xforms.

If this doesn't work, try adding a header to the page that indicates the content type is XHTML (not sure the right header info ATM).

Thanks for you advice, I tried to force the server to parse the php by adding the <Files directive, but it breaks the XForm - I got just back from browser just name of the labels.

I have tried various headers, but did not found the right one, none worked.

:?:

Thanks for you advice, I tried to force the server to parse the php by adding the <Files directive, but it breaks the XForm - I got just back from browser just name of the labels.

I have tried various headers, but did not found the right one, none worked.

:?:

Well, I'm not at all familiar with XFORMS, but you can use (assuming you're under Windows) Microsoft Fiddler to examine the data transferred. You can pick up the headers that are normally sent from your .xhtml file retrieval, and output the same from PHP.

MCP

You need to send this mime type with your PHP page and this should solve your problems: application/xhtml+xml

This article has been dead for over six months. Start a new discussion instead.