SitePoint Sponsor

User Tag List

Results 1 to 16 of 16
  1. #1
    SitePoint Zealot malluwood's Avatar
    Join Date
    Nov 2006
    Posts
    114
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Arrow php interview questions for beginers

    These are the some php interview questions from www.w3answers.com have answered for some questions

    1. What are the differences between Get and post methods in form submitting, give the case where we can use get and we can use post methods?

    get is like query string all the variables will be displayed in he url
    where as post is the standard way of sending th evariables
    When we submit a form, which has the GET method it displays pair of name/value used in the form at the address bar of the browser preceded by url. Post method doesn’t display these values.

    2. Who is the father of PHP and explain the changes in PHP versions?
    Father of php is Rasmus Lerdorf

    3. How can we submit a form without a submit button?
    Ans : I can submit a form in many ways, for e.g.
    1. When user click on checkbox, or drop down
    2. When user click on radio button
    3. At the end of the form I will type “Click here
    to submit” & link text to the processing file
    form.submit();

    4. In how many ways we can retrieve the date in the result set of mysql using PHP?

    5. What is the difference between mysql_fetch_object and mysql_fetch_array?

    mysql_fetch_object() is similar to mysql_fetch_array(), with one difference - an object is returned, instead of an array. Indirectly, that means that you can only access the data by the field names, and not by their offsets (numbers are illegal property names).
    mysql_fetch_object is like fetching value from a recordset
    and mysql_fetch_array is gettin array’s value

    6. What is the difference between $message and $$message?
    $message is variable whereas $$message is Dynamic variable.
    eg.

    $user=”bob”
    is equivalent to
    $holder=”user”;
    $$holder=”bob”;

    7. How can we extract string ‘abc.com ‘ from a string ‘http://info@abc.com’ using regular expression of PHP?
    $exploded[1] should have abc.com
    Use the function split split(“@”,”http://info@abc.com”) which returns an array any second element of the returned array will hold the value as abc.com.
    echo substr(”http://info@abc.com”,12,19);

    8. How can we create a database using PHP and mysql?
    mysql_create_db() should work

    9. What are the differences between require and include, include_once?

    require_once(),include_once() both the functions include and evalute the specified file only once
    and if the specified file is opened previous to the present call occurrance, it will not be done again.
    But require() and include() will do it as many times they are asked to do.
    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. The major difference between include() and require() is that in failure include produces a warning message whereas require produces a Fatal errors.

    10. Can we use include (”abc.PHP”) two times in a PHP page “makeit.PHP”?
    Yes we can include that many times we want, but here are some things to make sure of:
    (including abc.PHP, the file names are case-sensitive)
    there shouldnt be any duplicate function names, means there should not be functions or classes or variables with the same name in abc.PHP and makeit.php
    11. What are the different tables present in mysql, which type of table is generated when we are creating a table in the following syntax: create table employee(eno int(2),ename varchar(10)) ?
    Table Types are
    • ISAM(Index Sequential Access Method)
    • MyISAM
    o Static
    o Dynamic
    o Compress
    • Merge
    • Heap (Fastest tables because it stores in to the RAM)
    • BDB
    • InnoDB (Transaction safe table)
    When you fire the above create query MySQL will create the Dynamic table.
    12. Functions in IMAP, POP3 AND LDAP?

    13. How can I execute a PHP script using command line?
    Through php parse you can execute PHP script using command line. By default location of php parser is /var/www/html so set the path of this directory and just use as following
    #php sample.php
    14. Suppose your Zend engine supports the mode <? ?> Then how can u configure your PHP Zend engine to support <?PHP ?> mode ?
    In php.ini file:
    set
    short_open_tag=on
    to make PHP support

    15. Shopping cart online validation i.e. how can we configure Paypal, etc.?

    16. What is meant by nl2br()?
    nl2br() inserts html in string. echo nl2br(”god bless \n you”);
    output
    god bless
    you
    17. Draw the architecture of Zend engine?

    18. What are the current versions of apache, PHP, and mysql?

    19. What are the reasons for selecting lamp (linux, apache, mysql, PHP) instead of combination of other software programmes, servers and operating systems?

    20. How can we encrypt and decrypt a data present in a mysql table using mysql?

    21. How can we encrypt the username and password using PHP?
    You can encrypt a password with the following
    Mysql>SET PASSWORD=PASSWORD(“Password”);
    22. What are the features and advantages of object-oriented programming?

    23. What are the differences between procedure-oriented languages and object-oriented languages?

    24. What is the use of friend function?

    25. What are the differences between public, private, protected, static, transient, final and volatile?

    26. What are the different types of errors in PHP?
    Three are three types of errors 1) Fatal errors 2) Parser errors 3) Startup errors.
    27. What is the functionality of the function strstr and stristr?
    string strstr ( string str1, string str2) this function search the string str1 for the first occurrence of the string str2 and returns the part of the string str1 from the first occurrence of the string str2. This function is case-sensitive and for case-insensitive search use stristr() function.
    28. What are the differences between PHP 3 and PHP 4 and PHP 5?

    29. How can we convert asp pages to PHP pages?

    30. What is the functionality of the function htmlentities?

    31. How can we get second of the current time using date function?

    32. How can we convert the time zones using PHP?

    33. What is meant by urlencode and urldocode?
    string urlencode(str)
    where str contains a string like this “hello world” and the return value will be URL encoded and can be use to append with URLs, normaly used to appned data for GET like someurl.com?var=hello&#37;world
    string urldocode(str)
    this will simple decode the GET variable’s value
    Like it echo (urldecode($_GET_VARS[var])) will o/p “Hello world”
    34. What is the difference between the functions unlink and unset?

    35. How can we register the variables into a session?

    36. How can we get the properties (size, type, width, height) of an image using PHP image functions?

    37. How can we get the browser properties using PHP?


    38. What is the maximum size of a file that can be uploaded using PHP and how can we change this?

    39. How can we increase the execution time of a PHP script?

    40. How can we take a backup of a mysql table and how can we restore it. ?

    41. How can we optimize or increase the speed of a mysql select query?

    42. How many ways can we get the value of current session id?

    43. How can we destroy the session, how can we unset the variable of a session?

    44. How can we destroy the cookie?

    45. How many ways we can pass the variable through the navigation between the pages?

    46. What is the difference between ereg_replace() and eregi_replace()?
    eregi_replace() function is identical to ereg_replace() except that this ignores case distinction when matching alphabetic characters.
    47. What are the different functions in sorting an array?

    48. How can we know the count/number of elements of an array?

    49. What is the PHP predefined variable that tells the What types of images that PHP supports?

    50. How can I know that a variable is a number or not using a JavaScript?

    51. List out some tools through which we can draw E-R diagrams for mysql.

    52. How can I retrieve values from one database server and store them in other database server using PHP?

    53. List out the predefined classes in PHP?
    Predefined Classes
    1. Standard Defined Classes
    These classes are defined in the standard set of functions included in the PHP build.
    a. Directory
    The class from which dir() is instantiated.
    b.stdClass
    2.Ming Defined Classes
    These classes are defined in the Ming extension, and will only be available when that extension has either been compiled into PHP or dynamically loaded at runtime.
    a.swfshape b. swffill c. swfgradient d. swfbitmap e. swftext f. swftextfield
    g. swffont h. swfdisplayitem i. swfmovie j. swfbutton k. swfaction
    l. swfmorph m. swfsprite
    3. Oracle 8 Defined Classes
    These classes are defined in the Oracle 8 extension, and will only be available when that extension has either been compiled into PHP or dynamically loaded at runtime.
    a. OCI-Lob b. OCI-Collection
    4. qtdom Defined Classes
    These classes are defined in the qtdom extension, and will only be available when that extension has either been compiled into PHP or dynamically loaded at runtime.
    a. QDomDocument b. QDomNode
    54. How can I make a script that can be bilanguage (supports English, German)?

    55. What are the difference between abstract class and interface?

    56. How can we send mail using JavaScript?
    The answer for this question
    function myfunction(form)
    {
    tdata=document.myform.tbox1.value;
    location=”mailto:dep7abc@leeds.ac.uk?subject=”+tdata+”/MYFORM”;
    return true;
    }
    This question is wrong. You aren’t really ’sending mail’ when doing a ‘mailto’ and so it’s a misleading question… A smart candidate would just say “It’s not possible” and you may write him off.
    Last edited by malluwood; Aug 2, 2007 at 22:39.

  2. #2
    malloc
    Join Date
    Nov 2006
    Posts
    272
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The answers aren't brilliant I'm afraid. You've missed the mark on a few of them. Just some comments:

    1. The key difference between GET and POST is that POST has side-effects, and thus browsers will present a confirmation dialog to the user on refresh or "back".

    3. I suspect the key point is "using javascript"

    7. The question specifically says "using a regular expression", but you use other functions.

    16. More specifically nl2br converts newlines to html br tags

    21. Technically, this is using mysql not PHP. PHP has an md5 function that would normally suffice. Also, since the password function in mysql can change between versions, using mysql's md5 function would be better here. As an aside, concatonating the record id (or something else handy) before hashing will stop different users with the same password getting the same hash.

    26. There are more than 3: see http://uk.php.net/manual/en/ref.erro...func.constants for a full list.

  3. #3
    SitePoint Addict aniltc's Avatar
    Join Date
    Nov 2006
    Location
    INDIA
    Posts
    399
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Thumbs up

    Thanks for ur reply.

    But still there are questions which is unanswered

  4. #4
    SitePoint Wizard siteguru's Avatar
    Join Date
    Oct 2002
    Location
    Scotland
    Posts
    3,631
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    using mysql's md5 function would be better here.
    Did you mean that, or did you mean using PHP's md5() function would be better? (If using the PHP function then the MySQL version would not affect a PHP script).
    Ian Anderson
    www.siteguru.co.uk

  5. #5
    malloc
    Join Date
    Nov 2006
    Posts
    272
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Did you mean that, or did you mean using PHP's md5() function would be better? (If using the PHP function then the MySQL version would not affect a PHP script).
    What I meant was that using mysql's md5() function would be better than using mysql's password() function. Using PHP's md5() function would be even better, which is what my first statement meant. I probably should have worded it differently - hope this clarifies what I meant.

  6. #6
    SitePoint Wizard silver trophy
    Join Date
    Mar 2006
    Posts
    6,132
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by aniltc
    Thanks for ur reply.

    But still there are questions which is unanswered
    are you implying that you want us to give you answers to all of those unanswered questions?

    i can tell you right now, if you cannot answer those questions, even with the ability to use the manual as an open book, you probably arent going to last very long at that job. although, maybe you are just curious.

  7. #7
    SitePoint Wizard HarryR's Avatar
    Join Date
    Dec 2004
    Location
    London, UK
    Posts
    1,376
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hah very nice although some of the answers aren't too strong or fall back to using tertiary skills (which would be expected for any entry/junior level PHP developer) like JavaScript and generic SQL.

    Having recently taken part in a couple of interviews, I'd more be looking for general development skills rather than somebody's specific knowledge of a language (say 50/50 for a good entry-level candidate, going upto 70/30 or so for a more experienced position).

    Anyway a couple of interesting questions are:

    Q: Describe the process from a users web browser, to the web-server and back again.

    Q: How would you check that a string is a palindrome?
    *hint* using only one statement.

    Q: What's the maximum size of intergal numbers in PHP? How would you manipulate very large numbers? (e.g. 8+ billion)

    Q: What is 'htmlentities' and it's relationship with preventing XSS attacks/vulnerabilities?

    Q: Describe the differencesbetween the object models in PHP 4 and PHP 5.

    Oh and on a side note, if you can get through them easily and are looking for development work in London, UK - give me a PM for more details.

  8. #8
    Non-Member DelvarWorld's Avatar
    Join Date
    Jul 2004
    Location
    Baloney
    Posts
    341
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by HarryR View Post
    Q: How would you check that a string is a palindrome?
    *hint* using only one statement.
    Now this one got me thinking...there isn't a string reverse method in PHP as far as I know (and if there is then I feel like an idiot). With one line I'd try to solve it with something like

    PHP Code:
    if $test joinarray_reverse(explode($test)) ); 
    Is there a better way? Also, do I get the job

  9. #9
    SitePoint Wizard wonshikee's Avatar
    Join Date
    Jan 2007
    Posts
    1,223
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    Very interesting:

    PHP Code:
    $string "poop"# longest one I know

    echo (strtolower($string) == implode(''array_reverse(str_split(strtolower($string), 1)))) ? "yes" "no"
    Also it seems silly to expect someone to know what the max value of an INT is off the top of their head, particular PHP.

    I know its 2.1 something billion for signed, and doubled for unsigned but I wouldn't know unless I googled it to know exactly.

  10. #10
    hi galen's Avatar
    Join Date
    Jan 2006
    Location
    New Haven, CT
    Posts
    1,228
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code PHP:
     
    $word = 'racecar';
    echo ($word == strrev($word)) ? 'TRUE' : 'FALSE';

  11. #11
    SitePoint Wizard wonshikee's Avatar
    Join Date
    Jan 2007
    Posts
    1,223
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    Didn't know there was a strrev function. Good to know!

  12. #12
    SitePoint Member ronaldo30's Avatar
    Join Date
    Apr 2008
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Very useful test.

    Thanks!

  13. #13
    SitePoint Member
    Join Date
    Jul 2010
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hey thanks a lot for sharing useful interview questions..... which will be very helpful while attending the interviews.....
    glad i found ur site...really a very helpful site.....
    by the way check out my collection of php interview questions from here:php interview questions

  14. #14
    SitePoint Member
    Join Date
    Jul 2010
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by JonSiddle View Post
    The answers aren't brilliant I'm afraid. You've missed the mark on a few of them. Just some comments:

    1. The key difference between GET and POST is that POST has side-effects, and thus browsers will present a confirmation dialog to the user on refresh or "back".

    3. I suspect the key point is "using javascript"

    7. The question specifically says "using a regular expression", but you use other functions.

    16. More specifically nl2br converts newlines to html br tags

    21. Technically, this is using mysql not PHP. PHP has an md5 function that would normally suffice. Also, since the password function in mysql can change between versions, using mysql's md5 function would be better here. As an aside, concatonating the record id (or something else handy) before hashing will stop different users with the same password getting the same hash.

    26. There are more than 3: see http://uk.php.net/manual/en/ref.erro...func.constants for a full list.
    Hi,

    Thanks very much for this comment. It help me to think about my ideals.

    Tks again and pls keep posting.

  15. #15
    SitePoint Member
    Join Date
    Jul 2010
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by anbetophillip;
    Hi,

    Thanks very much for this comment. It help me to think about my ideals.

    Tks again and pls keep posting.
    Apart from that, this link below may be useful: Interview questions and answers

  16. #16
    SitePoint Wizard bronze trophy Immerse's Avatar
    Join Date
    Mar 2006
    Location
    Netherlands
    Posts
    1,661
    Mentioned
    7 Post(s)
    Tagged
    1 Thread(s)
    I love these questions. Whoever thought them up for interviewing people with should be fired.

    If a (potential) programmer doesn't know how to count() the elements in an array (q. 48), how on earth can you expect them to draw the architecture of the Zend engine (q. 17)? There are huge discrepancies in the levels of the questions.

    Unless of course they expect an answer like:

    Input -> Zend Engine -> Output -> Profit!



Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •