10 PHP Tips To Improve Your Programming

After the introduction of PHP in 1995,php has become the hot cake for every web developers. In this tutorial, you'll learn about advanced php tricks and techniques to improve your programming. These tips are:

1. Using a SQL Injection Cheat sheet

You might be wonder that, why i am talking about database. Reason is that almost every php application require database to store data. So, what is SQL Injection, sql injection is a method of hacking in which  hackers put some code to your database for monitoring the data flow. Here is the complete Cheat Sheat.
2. Knowing the difference b/w comparison operators

One thing about programmers is that every programmer doesn't know the difference b/w comparison operators. Following are the complete list of comparison operators:
 For example, "==" and "===" looks similar in one view. But there is a huge difference, "===" use for checking the identity and "==" use for checking the similarity. Further, all the details about comparison operators are available on the php official website.
3. Shortcut the "else" statement

Making the code simple, clean and easy to read is the good programming practice. For example see this example.
If, we want to make the variable '$x' by default to '10'. So, whey are we using extra 'else' statement. Correct code is in the following snapshot.

4. Dropping the brackets

In the third tip, we see that, how we are using brackets. This work fine, but not a good programming practice. Best way for brackets is something like that:
5. Use str_replace() instead of ereg_replace() and preg_relpace() functions

Sometimes in php, we start using ereg_replace() and preg_replace() functions for string manipulation. Purpose of telling this is that, these functions do not work for string manipulation, but efficiency of code decreases. Use str_replace() function instead of above. Those functions are best suited for regular expressions work.

6. Use of ternary operator

Ternary operator is a type of comparison operator and syntax for this is something like selected are in the following snapshot.
 If we are using, small conditions i-e two, then using of ternary operator is the best way instead of if and else, because ternary operator avoid extra spacing in the code.

7. Memcached


In the beginning, Memcached will look difficult, but this is the best caching application for speeding up the website. It generates the copy of your pages into simple html and store it, when everytime a visitor will come to this page, then instead of again processing the page, server will show this html page.

8. Using a framework

If you have some knowledge about php, then php frameworks will be the best way for creating web applications. Most popular frameworks are CodeIgniter, zend, CakePhp.

9. Using the error controlling operator correctly

Error controlling operators starts with @(art sign) and this operator only works in expressions. It generates the error when any expression is not working fine. Best usage of this operator is given in the following screenshot.

10. Using isset instead of strlen

When, you want to calculate the number of characters in a string, then 'strlen' comes to your mind. But strlen is not efficient way, use of 'isset' will generate sixty five percent quicker results. Following is the Detail explanation about this strategy.

20 comments:

  1. This site is truly amazing my one of friend told me about this. And the theme is quite beautiful as well as the updated stuff also attract visitors to come and visit again. I would definitely bookmark it and would come back to you soon. Keep on updating.

    ReplyDelete
  2. Nice blog post. I noticed this blog further more useful information. Thanks for sharing your useful views.
    Web Development Company in Chandigarh

    ReplyDelete
  3. Thanks for this useful post. For more visit: examanswer24.com

    ReplyDelete
  4. Thanks for letting me know about the 10 PHP tips to improve programming. This has been of great help to me.
    Web Design Company India

    ReplyDelete
  5. Thank you sharing this information thank you.Come back again for more interesting stuffs like one you got earlier! Bulk SMS in India

    ReplyDelete
  6. I like this tut.. please :)

    http://pinoysourcecode.blogspot.com/

    ReplyDelete
  7. Thanks so much for this helpful information come back again for more interesting information…Keep it up
    Builders in Agra

    ReplyDelete
  8. Great php tips for programming. It can help better for php developers.

    Wordpress Development Company

    ReplyDelete
  9. Now i am learner in php. I will use this great tips.

    Web Design Company

    ReplyDelete
  10. Hey nice blog,Thank's for this helpful information come back again for more interesting information…Keep it up!
    Taxi in Agra

    ReplyDelete
  11. Great php tutorials tips for programming. It can help better for php developers.Thanks for this useful post.

    ReplyDelete
  12. Thanks for such an interesting article here. I was searching for something like that for quite a long time and at last I have found it here.Web Designing Course in Jalandhar

    ReplyDelete
  13. Blogs are so informative where we get lots of information on any topic. Nice job keep it up!! forgings manufacturing

    ReplyDelete
  14. Your blog has given me that thing which I never expect to get from all over the websites. Nice post guys!


    regards,

    Melbourne web developer

    ReplyDelete
  15. Wonderful blogs for like PHP tips on the outputs with positively reply encouraged me to be more open and engaging in commenting.So know it's helpful.

    Web Designing Training in Chennai

    ReplyDelete
  16. Great post. Very useful infomation for all. Keep sharing. best php training in pune

    ReplyDelete
  17. How do I improve my PHP skills? A recurring question on various boards and chats. It’s often asked by newbies but even experienced developers ask themselves the same thing. After all trying to be better is in the human nature. I don’t think about that mastering PHP requires from 10 years but practicing is essential. The Obviously practice has must to be purposeful and otherwise it is useless.

    php training in chennai

    ReplyDelete
  18. A lot of coding best practices emphasize keeping code lean and well organized. The general practices within HTML are no different. The goal is to write well-structured and standards-compliant markup.

    dotnet training in Chennai

    ReplyDelete
  19. Given so much info in it, These type of articles keeps the users interest in the website, and keep on sharing more ... good luck...
    Hire PHP developer in India

    ReplyDelete
  20. create new file called config.localhost.php and copy paste this code (the database name, user and password should match your own mysql configuration) login exam

    ReplyDelete