Edit PHP as XHTML?

<oXygen/> general issues.
Posts: 104
Location: Victoria, BC, Canada

Edit PHP as XHTML?

Wed Feb 22, 2017 9:29 pm

Using the latest 18.1 editor:

I often have to edit PHP documents which are in fact well-formed XHTML5, and I'd like to be able to do that in Oxygen. I've tried two approaches: defining a new document type for *.php, and specifying that it's XML, and modifying the current XHTML document profile so that it also includes an association rule for *.php. Neither works; *.php documents just seem to be treated as text, and no well-formedness checking is available.

What am I missing?

Posts: 275

Re: Edit PHP as XHTML?

Thu Feb 23, 2017 3:48 pm

Hi Martin,

Actually, as PHP is a scripting language, not a markup language (like XML or XHTML), oXygen can not treat it as XML.
What can be done indeed (and I suppose that's also the case of the files you might be working with) is to embed PHP code in an XHTML document.
You can perform well-formedness checks over XML/XHTML files, but not directly on PHP code.

In case you have XHTML documents with embedded PHP code, but they have the .php extension, neither creating an additional document type association, nor editing an existing one is necessary to check them for well-formedness.
All you have to do in this case is associate the .php extension to the XML editor.
For that, you should go into menu Options > Preferences > File Types, look for the "php" extension in the list. By default, this should have "PHP editor" associated, so you should just edit the association and set the default editor to "XML Editor" instead. Apply the changes and you should be all set.

I hope this helps.

Costin Sandoi
oXygen XML Editor and Author Support

Return to “Other Issues”

Who is online

Users browsing this forum: Google [Bot] and 3 guests