Skip to main content


Showing posts from February, 2017

PHP Fresher Technical Interview Questions

PHP Fresher Technical Interview Questions Question : How to find out leap year? Answer:  A leap year is a calendar year containing one additional day. It has 366 days instead of the usual 365 days. function isLeapYear($year){   return ((0 == ($year % 4)) && (0 != ($year % 100)) || (0 == ($year % 400))); } var_dump(isLeapYear(2020)); Code Explanation: Every year that is exactly divisible by four is a leap year, except for years that are exactly divisible by 100, but these centurial years are leap years if they are exactly divisible by 400. Question : How to find out Prime number? Answer:   Prime number is a natural number greater than 1 that has no positive divisors other than 1 and itself. Function to check whether prime number or not function isPrimeNumber($num){ $flag = 0; for($i=2; $i<=$num/2; ++$i)     {         // condition for nonprime number         if($num%$i==0)         {             $flag=1;             break;         }     }    

PHP 7 Feautures

Performance Battle, PHP 7 vs. PHP 5 With virtually all updates, minor performance upgrades are to be expected. However, this time PHP brings a significant improvement over earlier versions making sheer performance one of PHP 7’s most attractive features. This comes as part of the “PHPNG” project, which tackles the internals of the Zend Engine itself. By refactoring internal data structures and adding an intermediate step to code compilation in the form of an Abstract Syntax Tree (AST), the result is superior performance and more efficient memory allocation. The numbers themselves look very promising; benchmarks done on real world apps show that PHP 7 is twice as fast as PHP 5.6 on average, and results in 50 percent less memory consumption during requests, making PHP 7 a strong rival for Facebook’s HHVM JIT compiler. Have a look at this infographic from Zend depicting performance for some common CMS and Frameworks. PHP 7 Syntactic Sugar PHP 7 comes with new syntax features. W

MySql Indexing

MySql Indexing A database index is a data structure that improves the speed of operations in a table.INSERT and UPDATE statements take more time on tables having indexes where as SELECT statements become fast on those tables. The reason is that while doing insert or update, database need to insert or update index values as well. Indexes are a way to avoid scanning the full table to obtain the result CREATE TABLE person ( last_name VARCHAR(50) NOT NULL, first_name VARCHAR(50) NOT NULL, INDEX (last_name, first_name) ); So if your index has two columns, say last_name and first_name, the order that you query these fields matters a lot. This query would take advantage of the index: SELECT last_name, first_name FROM person WHERE last_name = "John" AND first_name LIKE "J%" Using Create statement CREATE INDEX techsudhir_age ON employees(emp_name, emp_age); Alter command to update index ALTER TABLE person  ADD INDEX (name); Removing Indexes DROP