Tidy and PHP code question

Hello, I have tried using number tools to tidy up my PHP/HTML code correctly. The problem is when I have a line like:

<a href="http://<?php echo $row11['ad_link']; ?>"><img src="<?php echo $row11['photo']; ?>"  title="<?php echo $row11['ad_desc']; ?>" /></a>

It will come out like:

<a href="http://%3C?=$row11['ad_link'];?%3E"><img src=
"%3C?=$row11['photo'];?%3E" title=

Is there any possible way to FIX this please? Thank you!

II've tried using HTML Tidy (CLI version), PHP Tidy package, hindent, and htb so far. Are there any configuration options I must set to make ANY of work this correctly? Or recommendation for different program?
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Just wondering, Have you tried http://www.phpformatter.com/ ? or an online formatter wouldn't suit your needs ?

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Matthew KellyCommented:
Use html_entity_decode: http://www.php.net/manual/en/function.html-entity-decode.php
<a href="http://<?php echo html_entity_decode($row11['ad_link']); ?>"><img src="<?php echo html_entity_decode($row11['photo']); ?>"  title="<?php echo html_entity_decode($row11['ad_desc']); ?>" /></a>

Open in new window

Matthew KellyCommented:
Ignore my first post... one option is to replace the PHP start/end tags before tidying and then replace back:

From http://stackoverflow.com/questions/1262420/configure-html-tidy-to-ignore-php-short-start-and-end-tags-when-inside-html-attri
You could pre-process your php:

by adding comments by converting <? to <!--<?, and ?> to ?>-->

<input value='<?=$variable?>'>

would become

<input value='<!--<?=$variable?>-->'>

after running HTMLtidy, you would do the opposite.

pre-process by adding comment tags
run HTMLtidy
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

imagine7xyAuthor Commented:
That is really ghetto though. You would think there would be one decent PHP/HTML formatter out there... I finally decided to just use ob_start, however, Tidy is REALLY buggy with PHP, I don't know if I trust it.
imagine7xyAuthor Commented:
remorina:I already have a really nice PHP formatter that is part of PEAR called PHP_Beautifier, I just don't have a darn HTML one that doesn't mess with PHP. Even PHP's own Tidy module messes up PHP.
Have you tried http://www.mycoolform.com/index.php?lang=en-us,en;q=0.5

I personally use Visual Studio, which can still format php files, I just rename them to .htm and format them then it only takes a minute to make it suit my standards, second option is DreamWeavers code format which still works well and is also configurable, they both wouldn't mess with actual code or characters/symbols

Dreamweaver is great for code formatting, but it's not free :(

Netbeans is, though, and it's also a very very good editor! http://netbeans.org/
imagine7xyAuthor Commented:
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.