Monday, 29 October 2012

Top 15 PHP Web Development Tips and Tricks

PHP is probably one of the most widely used open source general-purpose scripting languages on the web. It is used to enhance web pages. With PHP, you can do things like create user id and password login web pages, check details from a form, create forums, blog, picture galleries, and a lot more. If the URL of the web page ends with .php, then the author has written some programming code to liven up the plain, old HTML.

- PHP stands for Hypertext Preprocessor
- PHP scripts are executed on the server
- PHP supports many databases like MySQL, Oracle, Sybase, PostgreSQL, Generic ODBC, etc.
- PHP is open source software
- PHP is free to use and download

15 PHP Web Development Tips and Tricks
PHP is most likely the preferred web development languages in the world. There are already over 20 million domains on the web that have made use of PHP Web Development techniques.

I have read about many of these points in books and online tutorials. Initially I ignored it but after that I realized its importance for security with PHP & MySQL, but I would like to suggest everyone who is new to PHP is to read these tips and apply them before you end up with a big confusion.

1. Echo() versus print():
Echo is quicker than print. Both functions are used for the same thing but echo is the language constructs which return nothing, which publish will return 0 or 1 based on success or failure.

2. Be sure to validate user input on the server side:
While validating user input with JavaScript, does it on the server side too, since for bypassing your JavaScript validation a user just needs to turn their JavaScript off. It is (JavaScript validation) is only good to reduce the server load.

3. Use single quotes for longer strings rather than double quotes
Because in double quotes it will search for PHP variable to evaluate them. So in this case, in single quotes is faster because it does not require any string manipulation.

4. Always escape the output:
It will avoid XSS (Cross Site Scripting) attacks. You have to be sure about it i.e., When displaying user input on a page use htmlentities($user_bio, ENT_QUOTES, ‘UTF-8′).

5. If you have declared a method as static then let it is the same, as its 33% quicker than member functions.



6. Try to use minimize relative paths:
For relative path insertion it will search for default include path then current directory then so on. As a result file search in that case may catch more time.

7. Identical operator (===) is faster than (==) operator as identical operator will include type checking also.

8. Avoid using short tags and try to use , It can generate a problem for you if you are available to organize your application on another server.

9.Echo’s multiple parameters:
For faster result, use echo's multiple parameters instead of string concatenation.

10. Specify full paths:
Try to use full paths in includes and requires, for less time spend on resolving the OS paths.

11. Derived classes vs. base classes:
You may have to know i.e., methods in derived classes run faster than ones defined in the base class.

12. About accessing arrays:
e.g. $row['id'] is 7 times faster than $row[id]

13. Do not implement every data structure as a class:
Avoid to being everything OOP, as often it is too much overhead, and each method and object call consumes more memory. For this case, do not implement every data structure as a class, arrays are useful, too.

14. Avoid functions inside loops:
Try to use functions outside loops. If not the function may get called each time.

15. Free unnecessary memory:
Unset your variables to free memory, especially large arrays.

19 comments:

  1. PHP can be really tricky if you really don’t know how to use it. But all the tips and tricks you’ve provided will definitely help beginners. Great post.

    ReplyDelete
  2. Wow! Awesome your sharing! your site is very effective and helpful. Thanks for sharing.
    VELKOMMEN

    ReplyDelete
  3. Wow! Awesome your sharing! Thanks for your sharing.

    ReplyDelete
  4. Thank you for your effort to discuss this matter. It was really informative.


    By
    Prasant Saxsena
    Web Development Consultancy

    ReplyDelete
  5. Its quite interesting about web development from this information. I like it. Thanks for the information.

    ReplyDelete
  6. This comment has been removed by the author.

    ReplyDelete
  7. The php is hypertext script, these is web programming language, which is used for website development, and php is also software developing program, many sites are developed in php, which is used to develop complex websites.these tips are good and easily followable.

    ReplyDelete
  8. That will really be great, i usually report if i come across blogs with nofollow attribute on the directory. But the new dimension you took is great, will be follow you now…
    atlanta seo

    ReplyDelete
  9. There's a lot of people love on designing in different ways. Designing helps people to be creative and it helps for their future in demand today's.
    web design courses

    ReplyDelete
  10. We all know that PHP is a flexible language when it comes to web coding, however it can get complicated and unorganized at times. Its always better to have a php developer or cakephp developer for your php development requirement.

    ReplyDelete
  11. There are a number of tricks that can make your web development easier and help you get performance from your website. These tricks can give you that little edge in performance you may be looking for. Thanks.


    web development perth

    ReplyDelete
  12. Hiring PHP developers are now in-demand and those tips you've given I think it is a big help for us to know more about php development. The information also are very useful. Thanks.

    ReplyDelete
  13. As you all know that PHP is a open source language. It is the only language which is mostly used worldwide. Here are some of the best web development tips and tricks.
    Direct Mail

    ReplyDelete
  14. Yes, these are looking prolific ideas for making your PHP web developing more efficient. Using single quotes is far better trick and I admit that could become mistake to implement every data structure.

    ReplyDelete
  15. I really Enjoy the reading on this post, please continue it.


    SEO Sydney | SEO Melbourne | SEO

    ReplyDelete
  16. Done a excellent job in this blog, Alternatively create a great blog for the readers specially for
    Web Development
    .

    ReplyDelete
  17. Yes absolutely right your website information about Web Design & Development. No doubt Best Web Design is changing your Business Quality and revenus: we design a customer needs website & Deliver quality of Web Designing
    Graphic designing

    ReplyDelete
  18. Definitely your publish provides a superb and helpful supply each audience should change. this can be really a requirement study and appreciate. Thanks lots for sharing!

    Php Web Development

    ReplyDelete
  19. I agree that PHP can be tricky but it's quite easy to learn considering the bulk of professionals who are always willing to help. These tips are examples of that.

    ReplyDelete

Waiting for your valuable comments and suggestions to make my blog more informative and helpful to needy one. Thanks in Advance....!!!

Just Make IT More Informative by Providing Valuable Suggestions:)