PHP Questions

31.  What does the PHP error ‘Parse error in PHP – unexpected T_variable at line x’ means?
 This is a PHP syntax error expressing that a mistake at the line x stops parsing and executing the program.

32.  What should we do to be able to export data into an Excel file?
 The most common and used way is to get data into a format supported by Excel. For example, it is possible to write a .csv file, to choose for example comma as separator between fields and then to open the file with Excel.

33.  What is the function file_get_contents() usefull for?
file_get_contents() lets reading a file and storing it in a string variable.


34. What is the difference between the functions unlink and unset?
unlink() deletes the given file from the file system.
unset() makes a variable undefined.
 

35. How many ways can we get the value of current session id?
session_id() returns the session id for the current session.
 

36. What are default session time and path?
default session time in PHP is 1440 seconds or 24 minutes
Default session save path id temporary folder /tmp
 

37. for image work which library?
we will need to compile PHP with the GD library of image functions for this to work. GD and PHP may also require other libraries, depending on which image formats you want to work with.
 

38. How can we get second of the current time using date function?
<?php
$second = date(“s”);
?>
 

39. What are the Formatting and Printing Strings available in PHP?

printf()-    Displays a formatted string
sprintf()-Saves a formatted string in a variable
fprintf()    -Prints a formatted string to a file
number_format()-Formats numbers as strings
 

40. How can we find the number of rows in a result set using PHP?
$result = mysql_query($sql, $db_link);
$num_rows = mysql_num_rows($result);
echo "$num_rows rows found";


Pageviews from the past week