






































































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
A variety of php-related topics, including magic constants, error handling, file uploads, array manipulation, and more. It provides answers to multiple-choice questions on these subjects, which can be useful for students studying php or preparing for exams. A broad range of php concepts and functions, making it a potentially valuable resource for university-level php courses. The questions and answers touch on topics such as session management, smtp email, array operations, and file handling, providing a comprehensive overview of essential php programming knowledge.
Typology: Exams
1 / 78
This page cannot be seen from the preview
Don't miss anything!
1. What is the best practice for running MySQL queries in PHP? Consider the risk of SQL injection. Answers: 1. Use mysql_query() and variables: for example: $input = $_POST[‘user_input’]; mysql_query(“INSERT INTO table (column) VALUES (‘”. $input. “‘)”); 2. Use PDO prepared statements and parameterized queries: for example: $input= $_POST[“user-input”] $stmt = $pdo- >prepare(‘INSERT INTO table (column) VALUES (“:input”); $stmt- >execute(array(‘:input’ => $input)); 3. Use mysql_query() and string escaped variables: for example: $input= $_POST[“user-input”] $input_safe = mysql_real_escape_string($input); mysql_query(“INSERT INTO table (column) VALUES (‘”. $input. “‘)”); 4. Use mysql_query() and variables with a blacklisting check: for example: $blacklist = array(“DROP”,”INSERT”,”DELETE”); $input= $_POST[“user-input”] if (!$array_search($blacklist))) mysql_query(“INSERT INTO table (column) VALUES (‘”. $input. “‘)”); 2. Which of the following methods should be used for sending an email using the variables $to, $subject, and $body? Answers: 1. mail($to,$subject,$body) 2. sendmail($to,$subject,$body) 3. mail(to,subject,body) 4. sendmail(to,subject,body) 3. Which of the following is used to maintain the value of a variable over different pages?
Answers:
27. What is the best way to change the key without changing the value of a PHP array element? Answers: 1. $arr[$newkey] = $oldkey; unset($arr[$oldkey]); 2. $arr[$newkey] = $arr[$oldkey]; unset($arr[$oldkey]); 3. $newkey = $arr[$oldkey]; unset($arr[$oldkey]); 4. $arr[$newkey] = $oldkey.GetValue(); unset($arr[$oldkey]); 28. What will be the output of the following code? <? echo 5 * 6 / 2 + 2 * 3; ?> Answers: 1. 1 2. 20 3. 21 4. 23 5. 34 29. Does PHP 5 support exceptions? Answers: 1. Yes 2. No 30.Which of the following is true about posting data using cURL in PHP? Answers:
42.Which of the following file modes is used to write into a file at the end of the existing content, and create the file if the file does not exist? Answers:
45.Which of the following is the operator with the highest precedence? Answers:
vec_add (&$a, $b) { $a[‘x’] += $b[‘x’]; $a[‘y’] += $b[‘y’]; $a[‘z’] += $b[‘z’]; } $a = array (x => 3, y => 2, z => 5); $b = array (x => 9, y => 3, z => -7); vec_add (&$a, $b); print_r ($a); ?> Answers: