PHP tips :

PHP tips :

1. Don’t use spaces to format your code, use tabs. Every space takes up 1 byte, every tab takes up 1 byte too. So if you are using 4 spaces to make 1 tab, you will have added unnecessary bulk (and CPU time) to your code.

2. If you are dealing with external variables through get/post. Always use $_POST[’variable’] or $_GET[’variable’]. Assuming $variable can open a huge security hole into your script. With the upgrade to PHP5, register_globals is turned off, by default - so scripts will be forced to use the above method.

Here is a code snippet to quickly gather $_GET and $_POST variables:

// $_POST[’form_name’] = ‘Sample’;

foreach ($_POST as $key => $value)
$$key = $value;

// Now $form_name = ‘Sample’;

Leave a Reply

You must be logged in to post a comment.


All material @ copyrighted by chrisranjana.com. If you want to link to this article you are welcome to do so. Unauthorized publication is strictly prohibited. This developer tutorial website contains articles by Php programmers , Software developers, Mysql programmers and asp c# programmers. This website also contains ajax tutorials and advanced mysql sql stored procedures and functions tutorials and sample codes.