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=
"&lt;?=$row11['ad_desc'];?&gt;"></a>

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?
imagine7xyAsked:
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.

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

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

0
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
un-pre-process...
-------------------
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy 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.
0
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.
0
remorinaCommented:
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



code-format.png
0
rjdownCommented:
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/
0
imagine7xyAuthor Commented:
k
0
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
PHP

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.