Question-81. How will you retrieve source filename using Exception class in PHP when error occurred ?

Answer- Using getFile() method of Exception class which returns source filename.

Question-82. How will you retrieve source line using Exception class in PHP when error occurred ?

Answer- Using getLine() method of Exception class which returns source line.

Question-83. How will you retrieve stack trace using Exception class in PHP when error occurred ?

Answer- Using getTrace() method of Exception class which returns array of the backtrace.

Question-84. How will you retrieve formatted string of trace in PHP when error occurred ?

Answer- Using getTraceAsString() method of Exception class which returns formatted string of trace.

Question-85. How will you get the current date and time using PHP ?

Answer- PHP’s time() function gives you all the information that you need about the current date and time. It requires no arguments but returns an integer.

Question-86. What is the purpose of getdate() function ?

Answer- The function getdate() optionally accepts a time stamp and returns an associative array containing information about the date. If you omit the time stamp, it works with the current time stamp as returned by time().

Question-87. What is the purpose of date() function ?

Answer- The date() function returns a formatted string representing a date. You can exercise an enormous amount of control over the format that date() returns with a string argument that you must pass to it.

Question-88. How will you connect a MySql database using PHP ?

Answer- PHP provides mysql_connect function to open a database connection.

connection mysql_connect(server,user,passwd,new_link,client_flag);

 

Question-89. How will you create a MySql database using PHP ?

Answer- PHP uses mysql_query function to create a MySQL database. This function takes two parameters and returns TRUE on success or FALSE on failure.

bool mysql_query( sql, connection );

 

Question-90. How will you close a MySql database using PHP ?

Answer- Its simplest function mysql_close PHP provides to close a database connection. This function takes connection resource returned by mysql_connect function. It returns TRUE on success or FALSE on failure.

bool mysql_close ( resource $link_identifier );

If a resource is not specified then last opend database is closed.