job interview questions php

Posted by Stephen thangaraj at 23:55

1. How do you access data submitted through GET or POST from a form?
To access data use $_GET and $_POST respectively. For instance if a form is submitted with a field named 'email' through post, then this becomes available as $_POST[email].

With GET, the information is posted in the URL so this is useful if you want to store or bookmark a URL that relies on parameterised data. However GET is less secure, and also has strict limits on the amount of data that can be sent.

2. Write a simple program to get a row of information from a database?
$myrow = mysql_query("SELECT name,email FROM visitors ORDER by name LIMIT 1");
$data = mysql_fetch_row($myrow);
$name = $data[0]; $email = $data[1];
echo "A row from the database is name $name and email $email";

3. What is the difference between include and require?
If you require a file and it cannot be found, the script will terminate with a fatal error. If you use include then you will get an error but the script will continue to execute. Therefore when the information you wish to reference from another file is essential to the correct running of a page, use require.

4. How do you remove the last letter from a string?
There are many ways to do this. An interviewer will be looking for you to use a compact method. Here is probably the simplest method:

$data = "One too many letterss"; $newdata = substr($data,0,-1);// now 'one too many letters'

5. What do you need to use the image functions in PHP?
You need to have access to the GD Library in order to use the image functions in PHP.

click the Below link download this file 

If you enjoyed this post and wish to be informed whenever a new post is published, then make sure you subscribe to my regular Email Updates. Subscribe Now!

Kindly Bookmark and Share it:



Have any question? Feel Free To Post Below:

Blog Archive


© 2011. All Rights Reserved | Interview Questions | Template by Blogger Widgets

Home | About | Top