Tidy Code

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
andym01480
Forum Contributor
Posts: 390
Joined: Wed Apr 19, 2006 5:01 pm

Tidy Code

Post by andym01480 »

I have learnt some stuff recently about tidy and thus more secure code...

Mainly using arrays for all data to be processed:
All input from $_GET, $_POST etc to be stored in an array eg $input()
Cleaned up (checked it is safe and what I wanted) input in a different array $clean()
Outputed data to browser where no html tags are wanted in another array $html() where htmlentities() has been applied
Outputed data to mysql stored in $mysql() which has been escaped

What other principles for tidier and more secure coding are there?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Consistency and highly readable code.
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

Good variable names, clean indenting, great commenting...
User avatar
Ollie Saunders
DevNet Master
Posts: 3179
Joined: Tue May 24, 2005 6:01 pm
Location: UK

Post by Ollie Saunders »

Code by these
Post Reply