Solved

PHP tidy code

Posted on 2007-11-15
15
1,069 Views
Last Modified: 2012-08-13
I am wondering if anyone knows of a PHP code tidier, I have seen: http://prettyprinter.de/ But try to tidy some PHP and it changes <b> to the &3t, like that and messes with my HTML.

Any suggestions on a PHP cody tidier?
0
Comment
  • 8
  • 7
15 Comments
 
LVL 21

Expert Comment

by:nizsmo
Comment Utility
You can try  SourceFormatX:
http://www.textrush.com/formatx.htm

Hope this helps.
0
 
LVL 21

Expert Comment

by:nizsmo
Comment Utility
Also for your HTML you can try this see how good it works:
http://www.phpbuilder.com/manual/en/ref.tidy.php
0
 
LVL 1

Author Comment

by:catonthecouchproductions
Comment Utility
I am also on a Mac any suggestions there?
0
 
LVL 21

Accepted Solution

by:
nizsmo earned 500 total points
Comment Utility
sorry not that i know of. Although time consuming, it may be best to tidy the code manually using a good editor, as i find that you know exactly what has been done to the code, instead of taking a chance where the code may be change in some way by the code tidier program.

Hope this helps in some way.
0
 
LVL 1

Author Comment

by:catonthecouchproductions
Comment Utility
Thats a good point, get you use to your own code, etc.
0
 
LVL 21

Expert Comment

by:nizsmo
Comment Utility
yep, and you know that you woudn't run into any trouble.
A good practice though is to try and keep your code tidy when writing it, so that you don't have to do this at the end!

Indentation and commenting your code is an essential practice to good programming for any language.
0
 
LVL 1

Author Comment

by:catonthecouchproductions
Comment Utility
I know :) I need to keep that in mind, haha.
0
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 21

Expert Comment

by:nizsmo
Comment Utility
All good :)

sorry i couldn't suggest a straight solution to your problem, but hopefully what i said has helped in some way.
0
 
LVL 1

Author Comment

by:catonthecouchproductions
Comment Utility
Thats fine! Thanks anyway. Have you tried that link you sent me? Just curious to see how well code tidiers work, trial run.

Ryan
0
 
LVL 21

Expert Comment

by:nizsmo
Comment Utility
Which one are you talking about? SourceFormatX?
I had that installed for a while, it does do a reasonable job at tidying it up, however I don't like the feeling of letting another program take control of my code, so eventually i abandoned it. :)
0
 
LVL 1

Author Comment

by:catonthecouchproductions
Comment Utility
Haha...yeah, I was talking about the PHP add on the php site. Are you talking about SourceFormatX?
0
 
LVL 21

Expert Comment

by:nizsmo
Comment Utility
Yes sorry was talking about the wrong thing:p

as for the other one, i used it a while back, it was OK.

There is this new one (HTML TIdy) for PHP5, looks very cool and easy to use if you are thinking about tidying up your code using php:
http://devzone.zend.com/node/view/id/761

0
 
LVL 1

Author Comment

by:catonthecouchproductions
Comment Utility
Oh nice, let me take a look at this, does that just do PHP? Or HTML/PHP as well.

I couldnt really tell from the site.
0
 
LVL 21

Expert Comment

by:nizsmo
Comment Utility
i think it does html side of things only (css, html, etc...not sure about javascript), as it is CALLED from PHP, so it can't tidy itseif :P
0
 
LVL 1

Author Comment

by:catonthecouchproductions
Comment Utility
Hahahaha valid point!

RYan
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

This article will explain how to display the first page of your Microsoft Word documents (e.g. .doc, .docx, etc...) as images in a web page programatically. I have scoured the web on a way to do this unsuccessfully. The goal is to produce something …
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now