19 May 2012

PHP Interview Questions 

? What is PHP
                PHP is a server-side scripting language and it stands for “PHP Hypertext Preprocessor”.
  
? Who is the father of PHP
                Rasmus Lerdorf .

? What is the difference between echo() and Print() 
                echo( ) is more faster than print( ), print( ) returns whereas echo( ) doesn’t return, echo has void return type, echo( ) prints multiple value without a blank space when separated by the commas whereas print( )
inserts a single blank space with each commas.

? What is the use (.) operator in PHP
                It is used to concatinate the two or more variables.

? What is the difference between $_GET , $_POST and $_REQUEST
               Both are used to retrieve the information from a form,like user input
in $_GET , input values are visible in the browser’s address bar but in case of $_POST it doesn’t
in $_GET variable has character length (Max. 100 character),$_POST have no length limit
we use $_GET when form method=”GET” and we use $_POST when method=”POST”. 
$_GET variable should not be used hen sending password or some sensitive information.
$_REQUEST contains the content of both $_GET ,$_POST and $_COOKIE. and it can be used to get
the result from form data sent with both GET and POST method.
  
? Do you heated about addslashes( ) in php
              Addslashes() function return a string with backslash before the predefined character.This function can be used to prepare a string for storage in a database and database query. The predefined characters are
  • single quote ( ‘ )
  • double quote ( “ )
  • backslash ( \ )
  • NULL 
? What will be the out put of following code 
   <?php 
               $x   =   10;
               $y   =    x;
               echo $$y;
     ?> 
                out put10
? What will be the out put of following code <?php $x=10; echo $$x;  ?>
                Nothing


? How do you define a constant
               Via define() directive, like define ("MYCONSTANT", 100);

? What are the differences between require and include, include_once
               All three are used to an include file into the current page. If the file is not present, require(), calls a fatal error, while in include() does not. The include_once() statement includes and evaluates the specified file during the execution of the script. This is a behavior similar to the include() statement, with the only difference being that if the code from a file has already been included, it will not be included again. It des not call a fatal error if file not exists. require_once() does the same as include_once(), but it calls a fatal error if file not exists.



No comments:

Post a Comment