[thelist] html conversion to xhtml within php files

Christian Heilmann codepo8 at gmail.com
Thu Jul 28 09:21:25 CDT 2005


> There's a php script I'd love to use on my site.  My site is written in
> xhtml/css, and I'd love to template the script the same way, but within
> the script's php files all the html, including within the "echo"
> portions, is written uppercase and in html 4.01. We're talking a couple
> dozen php files here, some of which are fairly large.  I tried
> converting a file using html tidy, which didn't work because it changed
> the dynamic urls within the a hrefs.  I tried using the convert to xhtml
> utility in dreamweaver, which worked on the actual html sections but not
> on any of the html stuff within the echo portions of the php code, which
> is a great deal of stuff in every single php file to go in and edit by
> hand. I understand that topstyle has a "convert uppercase to lowercase"
> utility, but that will probably mangle stuff within the php code that is
> uppercase and needs to stay that way, so it would have to be used in a
> highlight and convert manner, which is a scant step up from hand conversion.
> 
> Is there any program, preferably free or open source, that will do this
> easily without mangling code? I'd settle for a simple "convert uppercase
> html to lowercase html" and strip out the font, b and other old stuff
> myself if I had to.

I doubt that you can do that automatically with the PHP script,
however you can do it with the output. PHP in the newer versions
actually has a tidy wrapper that allows you to clean out generated
content with tidy:

http://www.zend.com/php5/articles/php5-tidy.php
http://uk2.php.net/tidy

However, as your PHP merrily mixes markup and business logic, it might
be a good idea to go for a cleaner templated solution anyways, as that
would tackle the cause, not the symptom.

HTH
Chris

-- 
Chris Heilmann 
Blog: http://www.wait-till-i.com
Writing: http://icant.co.uk/  
Binaries: http://www.onlinetools.org/


More information about the thelist mailing list