Common PHP question asked in interview
31. How is it possible to know the number of rows returned in result set?
The function mysql_num_rows() returns the number of rows in a result set.
32. Which function gives us the number of affected entries by a query?
mysql_affected_rows() return the number of entries affected by an SQL query.
33. What is the difference between mysql_fetch_object() and mysql_fetch_array()?
The mysql_fetch_object() function collects the first single matching record where mysql_fetch_array() collects all matching records from the table in an array.
34. How can we access the data sent through the URL with the GET method?
In order to access the data sent via the GET method, we you use $_GET array like this:
$variable = $_GET[“var”]; this will now contain ‘value’
35. How can we access the data sent through the URL with the POST method?
To access the data sent this way, you use the $_POST array.
Imagine you have a form field called ‘var’ on the form, when the user clicks submit to the post form, you can then access the value like this:
36. How can we check the value of a given variable is a number?
It is possible to use the dedicated function, is_numeric() to check whether it is a number or not.
37. How can we check the value of a given variable is alphanumeric?
It is possible to use the dedicated function, ctype_alnum to check whether it is an alphanumeric value or not.
38. How do I check if a given variable is empty?
If we want to check whether a variable has a value or not, it is possible to use the empty() function.
39. What does the unlink() function means?
The unlink() function is dedicated for file system handling. It simply deletes the file given as entry.
40. What does the unset() function means?
The unset() function is dedicated for variable management. It will make a variable undefined.