php test upwok answers
1. Which of the following will start a session?
Answers:
• session(start);
• session();
• session_start();
• login_sesion();
2. Which of the following is incorrect with respect to separating PHP code and HTML?
Answers:
• Use an MVC design pattern.
• As PHP is a scripting language, HTML and PHP cannot be separated.
• Use any PHP template engine e.g: smarty to keep the presentation separate from business logic.
• Create one script containing your (PHP) logic outputting XML and one script produce the XSL to translate the XML to views.
2. Which of the following will read an object into an array variable?
Answers:
• $array_variable = get_object_vars($object);
• $array_variable = (array)$object;
• $array_variable = array $object;
• $array_variable = get_object_vars $object;
3. Which of the following is correct about Mysqli and PDO?
Answers:
• Mysqli provides the procedural way to access the database while PDO provides the object oriented way.
• Mysqli can only be used to access MySQL database while PDO can be used to access any DBMS.
• MySQLi prevents SQL Injection whereas PDO does not.
• MySQLi is used to create prepared statements whereas PDO is not.
4. Which of the following characters are taken care of by htmlspecialchars?
Answers:
• <
• >
• single quote
• double quote
• &
• All of these
5. Which function can be used to delete a file?
Answers:
• delete()
• delete_file()
• unlink()
• fdelete()
• file_unlink()
6. What would occur if a fatal error was thrown in your PHP program?
Answers:
• The PHP program will stop executing at the point where the error occurred.
• The PHP program will show a warning message and program will continue executing.
• Since PHP is a scripting language so it does not have fatal error.
• Nothing will happen.
7. What is the correct way to send a SMTP (Simple Mail Transfer Protocol) email using PHP?
Answers:
• s.sendmail($EmailAddress, [$MessageBody], msg.as_string())
• sendmail($EmailAddress, «Subject», $MessageBody);
• mail($EmailAddress, «Subject», $MessageBody);
• <a href=»mailto:$EmailAddress»>$MessageBody</a>
8. Which of the following is not a PHP magic constant?
Answers:
• __FUNCTION__
• __TIME__
• __FILE__
• __NAMESPACE__
• __CLASS__
9. Which of the following is used to maintain the value of a variable over different pages?
Answers:
• static
• global
• session_register()
• None of these
10. Which of the following is not related to debugging in PHP?
Answers:
• watch
• PDO
• breakpoints
• call stack
11. Should assert() be used to check user input?
Answers:
• Yes
• No
12. Which function will suitably replace ‘X’ if the size of a file needs to be checked?
$size=X(filename);
Answers:
• filesize
• size
• sizeofFile
• getSize
12. Which of the following is not a predefined constant?
Answers:
• TRUE
• FALSE
• NULL
• __FILE__
• CONSTANT
1. Which of the following will start a session?
Answers:
• session(start);
• session();
• session_start();
• login_sesion();
2. Which of the following is incorrect with respect to separating PHP code and HTML?
Answers:
• Use an MVC design pattern.
• As PHP is a scripting language, HTML and PHP cannot be separated.
• Use any PHP template engine e.g: smarty to keep the presentation separate from business logic.
• Create one script containing your (PHP) logic outputting XML and one script produce the XSL to translate the XML to views.
2. Which of the following will read an object into an array variable?
Answers:
• $array_variable = get_object_vars($object);
• $array_variable = (array)$object;
• $array_variable = array $object;
• $array_variable = get_object_vars $object;
3. Which of the following is correct about Mysqli and PDO?
Answers:
• Mysqli provides the procedural way to access the database while PDO provides the object oriented way.
• Mysqli can only be used to access MySQL database while PDO can be used to access any DBMS.
• MySQLi prevents SQL Injection whereas PDO does not.
• MySQLi is used to create prepared statements whereas PDO is not.
4. Which of the following characters are taken care of by htmlspecialchars?
Answers:
• <
• >
• single quote
• double quote
• &
• All of these
5. Which function can be used to delete a file?
Answers:
• delete()
• delete_file()
• unlink()
• fdelete()
• file_unlink()
6. What would occur if a fatal error was thrown in your PHP program?
Answers:
• The PHP program will stop executing at the point where the error occurred.
• The PHP program will show a warning message and program will continue executing.
• Since PHP is a scripting language so it does not have fatal error.
• Nothing will happen.
7. What is the correct way to send a SMTP (Simple Mail Transfer Protocol) email using PHP?
Answers:
• s.sendmail($EmailAddress, [$MessageBody], msg.as_string())
• sendmail($EmailAddress, «Subject», $MessageBody);
• mail($EmailAddress, «Subject», $MessageBody);
• <a href=»mailto:$EmailAddress»>$MessageBody</a>
8. Which of the following is not a PHP magic constant?
Answers:
• __FUNCTION__
• __TIME__
• __FILE__
• __NAMESPACE__
• __CLASS__
9. Which of the following is used to maintain the value of a variable over different pages?
Answers:
• static
• global
• session_register()
• None of these
10. Which of the following is not related to debugging in PHP?
Answers:
• watch
• PDO
• breakpoints
• call stack
11. Should assert() be used to check user input?
Answers:
• Yes
• No
12. Which function will suitably replace ‘X’ if the size of a file needs to be checked?
$size=X(filename);
Answers:
• filesize
• size
• sizeofFile
• getSize
12. Which of the following is not a predefined constant?
Answers:
• TRUE
• FALSE
• NULL
• __FILE__
• CONSTANT
No comments:
Post a Comment