Php & Xhtml

Reply

Join Date: Oct 2006
Posts: 5
Reputation: greywolf is an unknown quantity at this point 
Solved Threads: 0
greywolf greywolf is offline Offline
Newbie Poster

Php & Xhtml

 
0
  #1
Nov 28th, 2006
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.
Reply With Quote Quick reply to this message  
Join Date: May 2006
Posts: 1,422
Reputation: stymiee is on a distinguished road 
Solved Threads: 35
Moderator
stymiee's Avatar
stymiee stymiee is offline Offline
He's No Good To Me Dead

Re: Php & Xhtml

 
0
  #2
Nov 28th, 2006
Did you give the page a .php file extension?
John Conde
Brainyminds | Merchant Account Services | I Love Code
IT'S HERE: Merchant Accounts 101 Everything you need to know about merchant accounts!
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 5
Reputation: greywolf is an unknown quantity at this point 
Solved Threads: 0
greywolf greywolf is offline Offline
Newbie Poster

Re: Php & Xhtml

 
0
  #3
Nov 28th, 2006
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?
Reply With Quote Quick reply to this message  
Join Date: May 2006
Posts: 1,422
Reputation: stymiee is on a distinguished road 
Solved Threads: 35
Moderator
stymiee's Avatar
stymiee stymiee is offline Offline
He's No Good To Me Dead

Re: Php & Xhtml

 
0
  #4
Nov 28th, 2006
Do you run apache?
John Conde
Brainyminds | Merchant Account Services | I Love Code
IT'S HERE: Merchant Accounts 101 Everything you need to know about merchant accounts!
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 5
Reputation: greywolf is an unknown quantity at this point 
Solved Threads: 0
greywolf greywolf is offline Offline
Newbie Poster

Re: Php & Xhtml

 
0
  #5
Nov 28th, 2006
Yes. (Version 2)
Reply With Quote Quick reply to this message  
Join Date: May 2006
Posts: 1,422
Reputation: stymiee is on a distinguished road 
Solved Threads: 35
Moderator
stymiee's Avatar
stymiee stymiee is offline Offline
He's No Good To Me Dead

Re: Php & Xhtml

 
0
  #6
Nov 28th, 2006
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:

  1. <Files file.xhtml>
  2. ForceType application/x-httpd-php
  3. </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).
John Conde
Brainyminds | Merchant Account Services | I Love Code
IT'S HERE: Merchant Accounts 101 Everything you need to know about merchant accounts!
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 5
Reputation: greywolf is an unknown quantity at this point 
Solved Threads: 0
greywolf greywolf is offline Offline
Newbie Poster

Re: Php & Xhtml

 
0
  #7
Nov 29th, 2006
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.

Reply With Quote Quick reply to this message  
Join Date: Sep 2006
Posts: 44
Reputation: MCP is an unknown quantity at this point 
Solved Threads: 3
MCP MCP is offline Offline
Light Poster

Re: Php & Xhtml

 
0
  #8
Nov 29th, 2006
Originally Posted by greywolf View Post
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
Reply With Quote Quick reply to this message  
Join Date: May 2006
Posts: 1,422
Reputation: stymiee is on a distinguished road 
Solved Threads: 35
Moderator
stymiee's Avatar
stymiee stymiee is offline Offline
He's No Good To Me Dead

Re: Php & Xhtml

 
0
  #9
Nov 29th, 2006
You need to send this mime type with your PHP page and this should solve your problems: application/xhtml+xml
John Conde
Brainyminds | Merchant Account Services | I Love Code
IT'S HERE: Merchant Accounts 101 Everything you need to know about merchant accounts!
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the PHP Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC