Accommodating SVG in (X)HTML 5
(X)HTML 5 is just around the corner, and the improved support for SVG is impressive. However, HTML 5 has been a moving target for quite some time, and full support for the new features will take some time.
In terms of current SVG support, it appears that browsers that build on Webkit (e.g., Safari, Chrome) will support inline SVG only if you’re using XHTML 5 (no support for HTML 5.) Of note, to get your pages parsed as XML, you’ll have to set the MIME type to “application/xhtml+xml”.
For a typical page request, PHP defaults to MIME type “text/html”, however the language easily allows you to change the MIME type of a response with one little line of code:
So, how do you handle this in Nephtali? Easy.
If you’re developing a site that is primarily XHTML 5, toss a the line of code in nregister.php to make that MIME type the default, as nregister.php runs for every request. For pages that are of a different MIME type, you can just call the function header() again in the Nephtali file for the page with the appropriate MIME type (a later call to header() overwrites a value set earlier in the script.)
And, as you’ve probably guessed from above, if only one page is XHTML 5, just toss the line of code in the Nephtali file for that specific page.
In either case, there are no framework-specific calls or functions, no vast amounts of code, just use the powerful PHP you’re already familiar with. Changing the MIME type within a Nephtali application is a snap.
That’s it, let the fun begin with HTML 5 and SVG.