Priti's Technical Corner

November 21, 2008

PHP Interview Questions


Question 1: What are the main features of PHP 5?

Answer 1 :

 Robust support for object-oriented programming.

  1. Mysqli extension which offers prepared statement, Bound input and output, subquery and other advance features.
  2. Introduction of libxml2 which is a w3c standardized class.
  3. SQLite is now bundled with PHP which supports Transactions, subqueries, triggers and many other advance features.
  4. Cleaner Error handling with exceptions.
  5. SPL-Standatd PHP Library: it provide interators which allow you to run for-each loop in directory listing,database results and XML documents.
  6. Code introspection using the reflection classes.

Question 2: which function is use to upload the files?.

Answer 2: move_uploaded_file. The function move tmp_file to the destination specified in function.

Question 3: Name super global arrays in PHP.

Answers3: $_GET,$_POST,$_REQUEST,$_SERVER,$_SESSION,$_COOKIES.

Question 4: opposite of explode function?

Answer 4:Implode()

Question5: what is difference between abstract class and interface.

Answer 5:

Abstract Class:

  1. you cann’t instantiate an abstract class.
  2. ‘extends’ keyword is used to inherit the functions and variable.\
  3. you can extend ONLY one class

Interface

  1. Only function signature is defined. The definition of functions will be in class which implements it.
  2. ‘implement’ keyword is use
  3. You can implement many interface 

Question 6: what is design pattern?

Answer 6: Design patterns are the standard solutions to common problem in object oriented software design. 

Question 7: Discuss common design patterns you have used in your projects?

Answer 7: The factory pattern is a class that has some methods that create objects for you and other I use is Singleton it can include one and only type of object at a time.

Advertisements

5 Comments »

  1. Thanks for the interview related posts. I’m about to go to my first interview. It’s good to know what to expect.

    Comment by Robert — December 3, 2008 @ 6:16 pm

  2. I have come across one of the weblog which is about the setter and getter in php

    For normal use we write like :
    class test {
    private $count;
    public function setCount( $value )
    {
    $this->count = $value;
    }
    public function getCount()
    {
    return $this->count;
    }
    }

    We can use this as one function like:

    class test {
    private $count;
    public function Count( $value = “” )
    {
    if( empty( $value ) )
    return $this->count;
    else
    $this->count = $value;
    }
    }

    The real difference in these both are no of functions called , second class is more like using logic with oops , you can use both . In my view use first class as thats the way a getter and setter should be called.

    Comment by Anant Singh — December 16, 2008 @ 11:42 am

  3. Use single quoted strings unless you need to interpolate variables into your string. This saves PHP the time to scan the string for contained variables and saves about 50% execution time.

    Comment by Anant Singh — December 16, 2008 @ 11:43 am

  4. How the COPY function work in php

    Comment by pankaj — October 6, 2009 @ 5:50 am

  5. COPY function copy file from source to destination.

    Example;
    $file = test.txt';
    $newfile = 'test.txt.bak';

    if (!copy($file, $newfile)) {
    echo "failed to copy $file...\n";
    }

    Comment by pritisolanki — October 6, 2009 @ 8:36 am


RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Create a free website or blog at WordPress.com.

%d bloggers like this: