Please use the below Tips at the time of developing a code.
1. If a method can be static, declare it static. Speed improvement is by a factor of 4.
2. echo is faster than print.
3. Use echo's multiple parameters instead of string concatenation.
4. Set the maxvalue for your for-loops before and not in the loop.
5. Unset your variables to free memory, especially large arrays.
6. Avoid magic like __get, __set, __autoload.
7. require_once() is expensive.
8. Use full paths in includes and requires, less time spent on resolving the OS paths.
9. If you need to find out the time when the script started executing, $_SERVER['REQUEST_TIME'] is preferred to time().
10. use regex instead of strncasecmp, strpbrk and stripos .
11. str_replace is faster than preg_replace, but strtr is faster than str_replace by a factor of 4.
12. If the function, such as string replacement function, accepts both arrays and single characters as arguments, and if your argument list is not too long, consider writing a few redundant replacement statements, passing one character at a time, instead of one line of code that accepts arrays as search and replace arguments.
13. It's better to use switch statements than multi if, else if, statements.
14. it’s better to use conditional statement instead of if else statements.
15. Error suppression with @ is very slow.
Php Developer
Information for virtual Web Technologies
Wednesday, March 31, 2010
Search Engine Optimization(SEO) Techniques
SEO is the process and practice of optimizing your website so that it ranks well on search engine results pages (or SERPs). When someone types a word or phrase into search engines (like Google) looking for your product, you want to appear on the first or second page of the search results.
Note:- some places i am using '?' symbol instead of '<' symbol.Please understand question-mark as less-than symbol.(because i cant use tags inside the post)
Please follow the below steps to improve your website's search engine ranking.
Note:- some places i am using '?' symbol instead of '<' symbol.Please understand question-mark as less-than symbol.(because i cant use tags inside the post)
Please follow the below steps to improve your website's search engine ranking.
- Domain & File Names:-Choose your site domain name that contains words from your primary keyword phrase. Your domain name should also be easy to spell and easy to remember. Your keyword phrase also should be a part of your file name.
Ex:- About Us page file name should be http://yourdomain.com/about-us.htm
Note:- A file with 3+ hyphens tends to look spammy and users may be hesitant to click on it. Use hyphens in URLs and file names, not underscores. Hyphens are treated as a “space,” while underscores are not. - Hierarchal Design:-The web pages you create should be in a hierarchal design with your home page at the top of the hierarchy. Every page of your website should be reachable by at least one static link.
Labels:
SEO
Friday, March 26, 2010
Maintaining Database Tables
MySQL provides a bunch of statements to allow you to maintain database table more efficiently. Those statements enable you to analyze, optimize, check, and repair the database table. Here you will learn them all together with examples.
Analyze table statement
Basically analyze table statement allow you to update cardinality of an index column. By updating cardinality, you can retrieve the database faster by utilizing all index features of database tables.
You will work with the employees and offices table in our sample database. Let’s follow the example bellow to understand more how analyze table statement works.
We can get the indexes information from employees table by executing the show index statement as follows:
Analyze table statement
Basically analyze table statement allow you to update cardinality of an index column. By updating cardinality, you can retrieve the database faster by utilizing all index features of database tables.
You will work with the employees and offices table in our sample database. Let’s follow the example bellow to understand more how analyze table statement works.
We can get the indexes information from employees table by executing the show index statement as follows:
SHOW INDEX FROM employees;
Labels:
MySQL
MySQL Storage Engines
MySQL supports various of table types or storage engines to allow you to optimize your database. The table types are available in MySQL are:
ISAM
ISAM had been deprecated and removed from version 5.x. All of it functionality entire replace by MyISAM. ISAM table has a hard size 4GB and is not portable.
MyISAM
MyISAM table type is default when you create table. MyISAM table work very fast but not transaction-safe. The size of MyISAM table depends on the operating system and the data file are portable from system to system. With MyISAM table type, you can have 64 keys per table and maximum key length of 1024 bytes.
- ISAM
- MyISAM
- InnoDB
- BerkeleyDB (BDB)
- MERGE
- HEAP
ISAM
ISAM had been deprecated and removed from version 5.x. All of it functionality entire replace by MyISAM. ISAM table has a hard size 4GB and is not portable.
MyISAM
MyISAM table type is default when you create table. MyISAM table work very fast but not transaction-safe. The size of MyISAM table depends on the operating system and the data file are portable from system to system. With MyISAM table type, you can have 64 keys per table and maximum key length of 1024 bytes.
Labels:
MySQL
Tuesday, March 23, 2010
PHP Performance Tuning By Configuring php.ini File
Follow the below settings for achieving better performace.
register_globals = Off
Register_globals is fortunately since PHP 4.2.0 is disabled by default. If this setting to On, it is possible to all super global associative array of records ($ _POST, $ _GET, $ _REQUEST, $ _SESSION, $ _COOKIE, $ _SERVER, etc.) as a variable access. $ _SERVER [ 'PHP_SELF'] then has the same content as $ PHP_SELF. And this is precisely what is a security risk if variables are not properly initialized. Therefore, these parameters are always off. If your own or third party scripts will no longer work, it is advisable to rewrite it rather than on register_globals to be on!
And quite incidentally eats memory, of course, to now back in the direction of performance-redirect, because every array entry must be an additional variable load.
expose_php = Off
This setting adds - if they are to On - any HTTP response header entry, that the page was created with PHP. This is unnecessary, because your users are not interested anyway. Interesting but very probably hackers, because the more the infrastructure on the one side, the easier it gets. And out of sight performance, the added header entry of course be transferred to the client. So better off to make.
register_globals = Off
Register_globals is fortunately since PHP 4.2.0 is disabled by default. If this setting to On, it is possible to all super global associative array of records ($ _POST, $ _GET, $ _REQUEST, $ _SESSION, $ _COOKIE, $ _SERVER, etc.) as a variable access. $ _SERVER [ 'PHP_SELF'] then has the same content as $ PHP_SELF. And this is precisely what is a security risk if variables are not properly initialized. Therefore, these parameters are always off. If your own or third party scripts will no longer work, it is advisable to rewrite it rather than on register_globals to be on!
And quite incidentally eats memory, of course, to now back in the direction of performance-redirect, because every array entry must be an additional variable load.
expose_php = Off
This setting adds - if they are to On - any HTTP response header entry, that the page was created with PHP. This is unnecessary, because your users are not interested anyway. Interesting but very probably hackers, because the more the infrastructure on the one side, the easier it gets. And out of sight performance, the added header entry of course be transferred to the client. So better off to make.
Labels:
PHP
Subscribe to:
Comments (Atom)