• Write a small function to calculate n to the power of n?

      0 comments

    In the above question the interviewer is expecting the logic behind the scene (Recursive). Actually he may directly ask you to write a recursive function to calculate N to the power of N, or given number to the power of N. Following is the simplest way that you can write a PHP recursive function for this functionality.

    
    function MyPow($r, $w){
     if($w==0)
      return 1;
     else
      return MyPow($r, $w-1) * $r;
    }
    
    echo MyPow(10, 2);
    

    Also this functionality substitutes by the pow() function in PHP.

  • Explain drupal flow of information among 5 main layers

      0 comments

    Basically, there are 5 main layers in Drupal where information flows,

    1. Data (Node, ETC)
    2. Modules
    3. Blocks and Menus
    4. User Permissions
    5. Template


    Data
    Base of the system is collection of Nodes. – the data pool

    Modules
    These are functional plugins that are either part of the Drupal core (they ship with Drupal) or they are contributed items that have been created by members of the Drupal community.

    Blocks and Menus
    This is the next layer where we find blocks and menus. Blocks often provide the output from a module or can be created to display whatever you want, and then can be placed in various spots in your template (theme) layout. Blocks can be configured to output in various ways, as well as only showing on certain defined pages, or only for certain defined users.

    User Permissions
    Here is the next layer where settings are configured to determine what different kinds of users are allow to work and see.

    Template
    This is mainly the site theme or the skin. This is made up predominantly of XHTML and CSS, with some PHP variables intermixed

    Understanding this flow of information is very important if you are facing A Drupal project targeted interview as the interviewer might test your overall knowledge  of  Drupal CMS by asking this sort of questions.