PHP Interview Question

Here are some latest and updated  php interview questions.Get latest interview question related to Web development.

PHP Interview Question
PHP Interview Question
  1. Who is father of PHP ?

Rasmus Lerdorf

  1. What is PHP ?

Hypertext Preprocessor is server side scripting language that allows the features of creating webpages dynamically .PHP         allows the webpage to connect with the database. PHP Scripts are executed on the server. Its syntax are mostly derived           from C and perl.

  1. What is echo in PHP ?

Echo is used to print data in webpage. eg. <?php echo “PHP Cluster”; ?>. This code will print text PHP Cluster on                     webpage.

  1. What is PEAR in PHP ?

PEAR(PHP Extension and Application Repository) is a framework and repository for reusable PHP components.It is a code       repository containing all type of PHP snippets and library.

  1. How to declare array in PHP ?

$arr= array(‘php’,’cluster’,’vikash’);

  1. How to include a file in PHP ?

To include a file in PHP we use include() or require() function.

  1. What is the best way to copy a file from within a piece of php code ?

Use the inbuilt copy() function

  1. In php which method is used getting browser properties ?

$_SERVER[‘HTTP_USER_AGENT’]

  1. LAMP

    Linux Apache Mysql PHP

  1. Which function is used to pick one or more random value from array() ?

Array_rand()

  1. Which type of variable have php ?

   Multitype variable

  1. Is PHP support Multiple inheritance ?

No, php do’t

  1. In PHP which is used as error control operator ?

  @

  1. What regrular expression are used in php ?

Posix extended and Perl Campatible Regular Expression (PCRE)

  1. Which function is used to check if a function is already defined ?

Bool function_exits(function name)

   16. Which function is used to terminate the script execution in php ?

Die()

  1. Which operator is used to concatenate two strings in php ?

Dot operator ( . )

  1. How to use cookie ?

setcookie(‘name of cookie’,’value of cookie’,’expire time’,’domain’,’path’);

setcookie(‘user’,’Vikash’,’time+3600’);

<?php

If(isset($_cookie[‘user’]))

{   print_r($_cookie[‘user’]);

}

Else

{

echo “cookie doesn’t exits”;

}

?>

  1. Is it possible to submit a form without submit button ?

Yes

  1. Which data type are treated as array ?

String

  1. Is php directly coded into XHTML documents ?

Yes

  1. Casting operator introduce in PHP is ——-?

Int 64

  1. The ——-function can be used to compare two strings using a case sensitive binary algorithm ?

Strcasecmp

  1. Which of the following function require allow_url_fopen must be enabled ?

(a) Include                  (b)     require                    (c) both

Ans: (C)

  1. Which of the following is not valid variable name ?

(a) $php-cluster-vikash        (b) $vik              (c)  $PhpClusterVikash              (d)  $php_cluster_vikash

Ans: (a)

Q. How many inbuilt function is used to retrieve data in php in result set of MYSQL?
In four ways we can fetch data
1) mysql_fetch_row.
2) mysql_fetch_array
3) mysql_fetch_object
4) mysql_fetch_assoc

Q. How to create database using PHP & MySQL?

Mysql_create_db(“Your database Name”);

Q. What is the difference between unlink and unset php inbuilt function?

Unlink() function deletes the given file name from file system.
Unset() function makes a variable undefined means variable without value.

Q. How to register a variable in session?

$_SESSION[‘name’] = “PHPCluster”

Q. How to check your PHP installation?

PHP provides mainly two types of interface which are :
CLI – Command Line Interface
CGI – Common Gateway Interface
If php is installed in your system in php directory You can check it via these method.

1) Run “phpphp -v” command to check the Command Line Interface (CLI).
2) Run “phpphp-cgi -v” command to check the Common Gateway Interface (CGI).

Q. What is the difference between function and method?

When a function is created inside a class then, it is called method but when declared outside a class/object   is called function.

 

class phpcluster{

public function cluster(){       // a called method

……..

}

}

function cluster(){               // a function not part of an object

Leave a Reply

Your email address will not be published. Required fields are marked *