How To Faster Your PHP Script?
Hello Friends today we will discuss here some tips about php how can you fast your php script, This tutorial will introduce the nice way that how to fast your PHP scripts!
So dear friends follow this tips in your Programming life and enjoy.
1. Echo is Faster than Print
PHP has two different functions which are usually used to output data to a client – echo and print. Echo is faster than print by about eight percent.
2. Static is Better
If you can declare something to be static, do it. A PHP script will be served at least two to ten times slower by Apache than a static HTML page. So, try to use more HTML pages and fewer server-side scripts. If you are working in OOP, if it can be a static method, declare it static. This will improve your speed by a factor of four.
3. Require() vs. Include()
require() and include() are pretty much identical in every way, except that require stops if the file is missing. However, as far as performance is concerned, there is very little difference. Also, whenever possible, use require() instead of require_once(). Using require is about a 3x to 4x speed-up over using require_once. Also, important to know, require_once() is expensive.
4. Echoing Strings
When you echoing strings it's actually faster to separate them by a comma instead of a dot. However, you should know this only works with echo – which is a function that can take several string arguments. Also, try to use echo's multiple parameters instead of string concatenation.
5. Arrays and Single Character Functions
If a function – like a string replacement function – will accept both arrays and single characters as arguments, and if your argument list isn't too long, try writing redundant replacement statements, instead of a line of code that accepts arrays as search and replace arguments.
6. Stick to Coding Standards
If you stick with coding standards it will make it a lot easier for you to understand other people's code, and in return they'll actually be able to understand yours.
7. Cache As Much As Possible
Try using memchached, a high-performance memory object caching system that speeds up dynamic web applications by alleviating the database load. Your PHP scripts are recompiled every time unless the scripts are cached. So, make sure to install a PHP caching product. This will increase your performance by 25-to-100% because it removes compile times.
So there you have it, seven tips that should help you save time and money in your web page design and development. One last tip for you, before you start bugging experts with questions (not that they wouldn't be happy to help) try doing a Google search. It's amazing the things you can learn by Googling. You can also connect with PHP Users' Groups all over the world where smart people gather to chat, help each other and explore ideas.
Thank you Friends for reading this post if you have any question please feel free comment , and keep visiting my blog daily.
So dear friends follow this tips in your Programming life and enjoy.
1. Echo is Faster than Print
PHP has two different functions which are usually used to output data to a client – echo and print. Echo is faster than print by about eight percent.
2. Static is Better
If you can declare something to be static, do it. A PHP script will be served at least two to ten times slower by Apache than a static HTML page. So, try to use more HTML pages and fewer server-side scripts. If you are working in OOP, if it can be a static method, declare it static. This will improve your speed by a factor of four.
3. Require() vs. Include()
require() and include() are pretty much identical in every way, except that require stops if the file is missing. However, as far as performance is concerned, there is very little difference. Also, whenever possible, use require() instead of require_once(). Using require is about a 3x to 4x speed-up over using require_once. Also, important to know, require_once() is expensive.
4. Echoing Strings
When you echoing strings it's actually faster to separate them by a comma instead of a dot. However, you should know this only works with echo – which is a function that can take several string arguments. Also, try to use echo's multiple parameters instead of string concatenation.
5. Arrays and Single Character Functions
If a function – like a string replacement function – will accept both arrays and single characters as arguments, and if your argument list isn't too long, try writing redundant replacement statements, instead of a line of code that accepts arrays as search and replace arguments.
6. Stick to Coding Standards
If you stick with coding standards it will make it a lot easier for you to understand other people's code, and in return they'll actually be able to understand yours.
7. Cache As Much As Possible
Try using memchached, a high-performance memory object caching system that speeds up dynamic web applications by alleviating the database load. Your PHP scripts are recompiled every time unless the scripts are cached. So, make sure to install a PHP caching product. This will increase your performance by 25-to-100% because it removes compile times.
So there you have it, seven tips that should help you save time and money in your web page design and development. One last tip for you, before you start bugging experts with questions (not that they wouldn't be happy to help) try doing a Google search. It's amazing the things you can learn by Googling. You can also connect with PHP Users' Groups all over the world where smart people gather to chat, help each other and explore ideas.
Thank you Friends for reading this post if you have any question please feel free comment , and keep visiting my blog daily.
0 comments:
Post a Comment