Priti's Technical Corner

December 6, 2008

PHP Interview Questions

Filed under: PHP — Tags: , , , , — pritisolanki @ 6:02 pm

Question 1: What is the difference between htmlentities() and htmlspecialchars() ?

Answer 1:

htmlentities() : will convert all special characters to HTML entities.

htmlspecialchars() : It will convert some special characters to HTML entities.

Question2: What is difference between unlink() and unset();

Answer 2: unlink() is used to delete a file where as unset is used to unset the variable’s value or destroy the previously declared variable

Question3: What are the php.ini setting for controlling file upload file size.

Answer 3: post_max_size – Max size of message/file that can be posted by PHP.

file_uploads should be On

upload_tmp_dir – tmp dir path.

Upload_max_filesize – Max file size that can be uploaded.

Question 4: What all information you can have after you upload a file in PHP.

Answer4: name,type,size,error,tmp_name.

Question 5: what is difference between echo and print ();
Answer 5: echo is language construct where as print() is a function which return int value 1.



  1. when to use the GET and when to use the POST methods?

    GET sends form variables inthe URL, while POST sends them in the request body. So if you’re using GET, depending on what characters are being passed from your form, you may need to URL encode them. In fact, URL encoding is always a good idea no matter the circumstances. Users will also be able to see the variables being sent with the GET method as it results in an ugly URL. With POST the user will not be able to see the variables that are sent.

    I have solely used POST as far as I can remember. I haven’t found a need for GET out of necessity or otherwise. The only reason I can see to use GET is if your processing page is on another site since you wouldn’t be able to pass POST variables.

    Comment by Anant Singh — December 16, 2008 @ 5:07 pm

  2. Question. How can I maintain the count of how many persons have hit my site?
    Answer. The IP of a visitor can be tracked by $ip = $_SERVER[‘REMOTE_ADDR’];
    Just insert this value with date into a table.

    Question. What is difference between mysql_fetch_array(), mysql_fetch_row() and mysql_fetch_object()?
    mysql_fetch_array()– Fetch records from a table in the form of array.Which can be accessible through index.
    mysql_fetch_row():Fetch single row.
    mysql_fetch_object():Fetches result as object.

    Comment by Iqbal Husain — December 17, 2008 @ 1:38 pm

  3. How u can change the TABLE type in DATABASE

    Comment by pankaj — October 5, 2009 @ 9:37 am

  4. Hi Pankaj,

    Try using this query to fetch new queries that can alter storage engine type, further you may use FOR loop to execute this

    select CONCAT(‘ALTER TABLE ‘, TABLE_SCHEMA, ‘.’, TABLE_NAME, ‘ ENGINE=Innodb;’) as NewQry from information_schema.tables where ENGINE = ‘MYISAM’;

    Comment by Srivathsa — October 13, 2009 @ 9:26 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: Logo

You are commenting using your 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

Blog at

%d bloggers like this: