• 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.

  • What are the two new error levels introduced in PHP5.3?

      0 comments

    E_DEPRECATED

    The E_DEPRECATED error level is used to indicate that a function or feature has been deprecated.

    E_USER_DEPRECATED

    The E_USER_DEPRECATED level is intended for indicating deprecated features in user code, similarly to the E_USER_ERROR and E_USER_WARNING levels.