Top Interview Questions and Answers

Top Interview Questions and Answers
Interview Sortout

Browsing "Older Posts"

Browsing Category "Articles"

What is New In CodeIgniter 4.x?

By Dhananjay → December 4, 2018

Jquery noConflict()

By Dhananjay → September 21, 2018
What is noConflict() method in jQuery?
This is very important to differentiate scripts when we are using many JavaScript framework in our project.As we know jQuery uses dollar symbol ($) as shortcut. There are many other popular frameworks are there as Angular JS,Knockout JS,Kendo JS,Backbone JS,Ember ,Vue etc.
Suppose i one of these frameworks is using the $ symbol as shortcut then one of the scripts either jQuery or othe framework implemented parallel may stop working. noConflict is a method to avoid such situation in script.

We can create our self defined symbol or string as shortcut for jQuery. noConflict() return a reference and we can store this reference in a variable.

Example of noConflict() and self defined shortcut:

var jq = $.noConflict();
        jq("p").text("Hi there,Conflict resolved");

80 PHP functions asked in any Interview

By Dhananjay → September 11, 2018
This post contains the list of PHP functions that are frequently asked in various interview from freshers as well as experienced candidates. These are the parts of basic and core PHP. One must be familiar with these functions, I have just mentioned the definition in one line for each functions.They are frequently used in our application. Hope you will find this helpful.
  1. strlen() : returns the length of string passed.
  2. stristr() : returns rest of the string after the first occurence of a string in another string.
  3. stripos() : find the position of the first occurence of the string in another string.
  4. strip_tags() : returns string from html tags.
  5. strchr() : find first occurence of a string in another string and returns rest of the string.
  6. str_word_count() : returnd number of words in a string.
  7. str_split() : returns an array of charecters that string contains, when passed to it.
  8. str_replace() : search and replace a substring in a string by another substring.
  9. str_pad() : provide a virtual length to a string. It adds desired charecter to a string to make it up to required length.
  10. str_repeat() : Return a repeated string by a number of times.
  11. str_getcsv() : Parse a string to get the fields for CSV.
  12. rtrim() : remove white spaces from a string from right side.
  13. ord() : When we need to find ASCII value of the first charecter of the string we use ord().
  14. nl2br() : Conver all the new line charecters to BR tag of HTML.
  15. strstr() : returns rest of the string after the first occurence of a string in another string, find only case sensitive string.
  16. strtok() : breaks a strings into substrings
  17. strtoupper() : convert the case of string into uppercase.
  18. strtolower() : convert the case of string into lowercase.
  19. substr() : return a substring from a string of a length and from starting position.
  20. trim() : removes the white spaces from a string from left and right.
  21. ucfirst() : convert the case of first letters of all words in a string to uppercase.
  22. wordwrap() : break lines after a length.
  23. print() : output the result string when passed to it.
  24. print_r() : prints a resources ,object or an array along with the indexes.
  25. unlink() : delete a file from its location.
  26. unset() : set the value of a variable undefined.
  27. isset() : check whether the variable is defined or not.
  28. empty() : check whether an array is empty.
  29. array_chunk() : breaks an array into chunks of small arrays.
  30. array_combine() : combine two arrays of equal size where one is used for keys and another one is used for values.
  31. array_count_values() : count and returns the number of values of an array
  32. array_diff() : returns an array having difference between two arrays.
  33. array_flip() : flip key and value simultaneously.
  34. array_filter() : filter the values of an array based on a callback function.
  35. array_key_exists() : returns true if a key exists in an array.
  36. array_keys() : returns the array of keys from an array.
  37. array_map() : apply some operation on each value of an array and return a new array with modified values.
  38. array_merge() : merge the values of two array while retaining their keys.
  39. array_merge_recursive() : merge multidimensional arrays.
  40. array_push() : add a new value in an array at the end.
  41. array_rand() : select some random keys from an array.
  42. array_replace() : replace values in an array from the values in another array.
  43. array_reverse() : reverse the order of array and return new array.
  44. array_search() : search a value in an array and return the key of the value.
  45. array_shift() : remove the first element in an array.
  46. array_sum() : sum up all the values in an array.
  47. array_unique() : remove all the replicated values in an array.
  48. array_values() : returns an array of values with numeric index.
  49. array_walk() : Go to each value and run over an user defined function.
  50. array_walk_recursive() : Does the same recursively for an array.
  51. compact() : The compact() function creates an array from variables and their values.
  52. asort() : Sort an array values in ascending order.
  53. arsort() : Sort an array values in descending order.
  54. in_array() : returns true if a value find in an array.
  55. key() : return the key from the current pointer position.
  56. krsort() : sort and array based on keys and in descending order.
  57. ksort() : sort and array based on keys and in ascending order.
  58. range() : create an array from the range passed to it.
  59. date_create() : create a new dateTime object.
  60. date_create_from_format() : Create a user defined date from given format.
  61. date_diff() : returns difference between two dates.
  62. date_sub() : suntracts some period of time from a given date.
  63. date() : output the current date and time based on parameters given to it.
  64. gettimeofday() : output current time.
  65. gmmktime() : output UNIX time for GMT.
  66. localtime() : returns local time as UNIX timestamp.
  67. strtotime() : convert a string having datetime information into UNIX date.
  68. time() : eturn the current time.
  69. ceil() : returns the next interger value of the floating number passed to it.
  70. floor(): returns the next lowest integer value
  71. abs() : returns the absolute value passed to it.
  72. base_convert() : convert the base of number system.
  73. is_nan() : check whether a value is Not a Number.
  74. is_infinite() : check wherther a value is Infine.
  75. max() : find the max value from an array.
  76. min() : find minimum value from an array.
  77. mt_rand() : based on Mersenne Twister algorithm creates a random number.
  78. rand() : generate a random number
  79. round() : returns a floating point number up to a particular place of decimal point.
  80. sqrt() : returns the square root of the value passed to it.

Hooks in CodeIgniter

By Dhananjay →

Hooks in CodeIgniter

In code igniter hooks are the points before and after the execution where we can call some specific functions. These functions are called hooks and points where we call hooks are called hook point. Hooks are usefull when we have to make some changes throught the application , then we can do this without hacking all the files, just adding one hook at appropriate point. We can modify the way of usual rendering in code igniter application. So hooks facilitates modification in functionality without changing the core.

How we can use a hook in code igniter framework?
Before we use any hook in application we need to enable the hook in config.php file.Set the enable_hook config variable : TRUE,

$config['enable_hooks'] = TRUE;

The framework provide number of Hook Points to ease the development and modification in application:

The pre_system is called very early during system execution. Only the benchmark and hooks class have been loaded at this point.

As per the name just called before any of your controllers being called. When all the base classes are loaded, routing and security checks are done a pre_controller hook is called.

The hook is called just after the controller class instantiated but none of the method is called.

Called immediately after your controller is fully executed.

We have the _display() function in our core and we use it to render our view on browser after execution of all programms.
display_override allow use to display our own content at desired places.

$this->CI => get_instance();

We can call our own function instead of _display_cache() function using the cache_override hook. We can define our own cache display mechanism.

At the end of the system execution when final rendering is done post_system is called.

Define a hook :
A hook is defined in the hooks.php file located at application/config

Example for define a pre_controller hook:

$hook['pre_controller'] = array(  
            'class' => 'Classname',  
            'function' => 'functionname',  
            'filename' => 'filename.php',  
            'filepath' => 'hooks',  
            'params' => array('element1', 'element2', 'element3')  

Wordpress Dashboard - Tutorial 4

By Dhananjay → September 10, 2018

Admin Login

  • Give the user name and password .
  • Check the remember box as the browser will remind the login and password next time.

Dashboard area contains the following main tools and links:
  • Welcome section
  • Main menu(side menu)
  • Top menu
  • Admin area
  • Screen option
  • Help option
  • Quick draft section
  • At a glance section
  • Activity section

Welcome Section
  • This section has some important links which used frequently.
  • We can customize our site look as we click on Customize Your Site button.
  • Direct links to add an about page, to write the first blog.
  • We can turn on/turn off comments by external user on our posts from here.
  • We can visit our menu and widget systems from the link given.  

Screen Options:
  • Screen option shows a group of check boxes.
  • Each check box is for a particular section.
  • If it is checked the section is on the screen on the dashboard .
  • Unchecked boxes hide the section from dashboard.
  • Ex - we have to hide the Welcome section from screen. We will uncheck it.

WordPress Installation : Tutorial 3

By Dhananjay →

WordPress Installation
Before install a WordPress we should ensure that we have already created a database , where we have to create the WordPress tables with a prefix name .Default is prefix is wp_. We should have the following information as we are going to install the WordPress:
  • Database Name: wordpress
  • User name: root
  • Password: by default blank
  • Hostname:localhost
  1. Put the database name as you have created in the database field. It appears “wordpress” by default.
  2. Give the mysql user name, which is root by default.
  3. Give the password of mysql , if you have’n define , then let the password field blank.
  4. Give the host name as running on default port, localhost.
  5. Give a prefix for the table name , which are being install in database.
A wp-config.php file is created, containing the information about database, username, password etc, at the time of installation.

Wordpress Minimum Requirement : Tutorial 2

By Dhananjay →

Chapter:2-Before Installation
Minimum Requirement of a system to run the WordPress
  • We need a server to run the PHP script, because PHP is a server side script and WordPress is based on PHP.
  • WAMP Server which is-Windows Apache MySQL PHP
  • Download Source code of WordPress from:
  • Latest version of WordPress is wordpress-3.8.1 (as on 03-04-2014)
  • Latest of WAMP is 2.2 having
    • Apache 2.2.22
    • Mysql 5.5.24
    • PHP 5.3.13
    • PhpMyadmin
  • Apache is an open source web server , which is available in free. Apache is the one of the most popular and the most lovable web server by the web developers across the world.
  • Separately we can download from:
  • MySQL is the most preferred open source RDBMS .
  • Very identical to MSSQL and other RDBMSs.
  • PHP(PHP Hypertext Preprocessor) is an open source server side scripting language having the features of OOPS and syntax similar to C Programming and Perl.
  • PHP provide a rich library to manipulate data and make most of the complicated data operations easy.

WordPress Inroduction : Tutorial 1

By Dhananjay →

Chapter1: WordPress Inroduction
What is WordPress:
  • WordPress is a world famous Open Source CMS. Based on PHP as an open source server side scripting language.
  • WordPress is a free and open source blogging tool and a content management system (CMS) based on PHP and MySQL, which runs on a web hosting service.Features include a plug-in architecture and a template system.
  • WordPress is used by more than 18.9% of the top 10 million websites as of August 2013. WordPress is the most popular blogging system in use on the Web, at more than 60 million websites.
  • Architecture of template:

  • WordPress started in 2003 with a single bit of code to enhance the typography of everyday writing and with fewer users than you can count on your fingers and toes. Since then it has grown to be the largest self-hosted blogging tool in the world, used on millions of sites and seen by tens of millions of people every day.
  • It was first released on May 27, 2003, by its founders, Matt Mullenweg and Mike Little,as a fork of b2/cafelog. As of February 19, 2014, version 3.8 had been downloaded more than 20 million times.The license under which WordPress software is released is the GPLv2 (or later) from the Free Software Foundation.

Content Management Bystem (CMS) 
  • A Computer Application that allows publishing, editing and modifying content  as well as maintenance from a central interface.
  • CMSs are often used to run websites containing blogs, news, and shopping. Many corporate and marketing websites use CMSs. CMSs typically aim to avoid the need for hand coding but may support it for specific elements or entire pages.
  • The function and use of content management systems is to store and organize files, and provide version-controlled access to their data. CMS features vary widely. Simple systems showcase a handful of features, while other releases, notably enterprise systems, offer more complex and powerful functions. Most CMS include Web-based publishing, format management, revision control (version control), indexing, search, and retrieval. The CMS increments the version number when new updates are added to an already-existing file.

Architecture of wordpress template: