100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached
logo-home
PHP Exam Answered 2024. $14.39   Add to cart

Other

PHP Exam Answered 2024.

 4 views  0 purchase
  • Course
  • Online PHP
  • Institution
  • Online PHP

PHP Test 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...

[Show more]

Preview 4 out of 78  pages

  • August 26, 2024
  • 78
  • 2024/2025
  • Other
  • Unknown
book image

Book Title:

Author(s):

  • Edition:
  • ISBN:
  • Edition:
All for this textbook (2)
  • Online PHP
  • Online PHP
avatar-seller
Topscorer
PHP Test

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:

1. static

2. global

3. session_register()

4. None of these

4. Which of the following will check if a function exists?

Answers:

1. function_exists()

2. has_function()

3. $a = “function to check”; if ($a ()) // then function exists

4. None of these

5. Which of the following is not a file-related function in PHP?

Answers:

1. fclose

2. fopen

3. fwrite

4. fgets

5. fappend

6.Which of the following is true about the singleton design
pattern?

Answers:

1. A singleton pattern means that a class will only have a single
method.

, 2. A singleton pattern means that a class can have only one
instance object.

3. A singleton pattern means that a class has only a single member
variable.

4. Singletons cannot be implemented in PHP.

7. Which of the following characters are taken care of by
htmlspecialchars?

Answers:

1. <

2. >

3. single quote

4. double quote

5. &

6. All of these

8. Which of the following will read an object into an array
variable?

Answers:

1. $array_variable = get_object_vars($object);

2. $array_variable = (array)$object;

3. $array_variable = array $object;

4. $array_variable = get_object_vars $object;

9. Which of the following variable declarations within a class is
invalid in PHP?

Answers:

, 1. private $type = ‘moderate’;

2. internal $term = 3;

3. public $amnt = ‘500’;

4. protected $name = ‘Quantas Private Limited’;

10. Which of the following is not a PHP magic constant?

Answers:

1. __FUNCTION__

2. __TIME__

3. __FILE__

4. __NAMESPACE__

5. __CLASS__

11. Which of the following will print out the PHP call stack?

Answers:

1. $e = new Exception; var_dump($e->debug());

2. $e = new Exception; var_dump($e->getTraceAsString());

3. $e = new Exception; var_dump($e->backtrace());

4. $e = new Exception; var_dump($e->getString());

12. What will be the output of the following code?
<?php
var_dump (3*4);
?>

Answers:

1. int(3*4)

The benefits of buying summaries with Stuvia:

Guaranteed quality through customer reviews

Guaranteed quality through customer reviews

Stuvia customers have reviewed more than 700,000 summaries. This how you know that you are buying the best documents.

Quick and easy check-out

Quick and easy check-out

You can quickly pay through credit card or Stuvia-credit for the summaries. There is no membership needed.

Focus on what matters

Focus on what matters

Your fellow students write the study notes themselves, which is why the documents are always reliable and up-to-date. This ensures you quickly get to the core!

Frequently asked questions

What do I get when I buy this document?

You get a PDF, available immediately after your purchase. The purchased document is accessible anytime, anywhere and indefinitely through your profile.

Satisfaction guarantee: how does it work?

Our satisfaction guarantee ensures that you always find a study document that suits you well. You fill out a form, and our customer service team takes care of the rest.

Who am I buying these notes from?

Stuvia is a marketplace, so you are not buying this document from us, but from seller Topscorer. Stuvia facilitates payment to the seller.

Will I be stuck with a subscription?

No, you only buy these notes for $14.39. You're not tied to anything after your purchase.

Can Stuvia be trusted?

4.6 stars on Google & Trustpilot (+1000 reviews)

70840 documents were sold in the last 30 days

Founded in 2010, the go-to place to buy study notes for 14 years now

Start selling
$14.39
  • (0)
  Add to cart