1. What is the best practice for running MySQL queries in PHP? Consider the risk of SQL injection.
Answers:
Answers:
Answers:
Answers:
Answers:
Answers:
Answers:
Answers:
Answers:
Answers:
Answers:
<?php
var_dump (3*4);
?>
Answers:
Answers:
Answers:
Answers:
<?php
function Expenses()
{
function Salary()
{
}
function Loan()
{
function Balance()
{
}
}
}
?>
Which of the following sequence will run successfully?
Answers:
Answers:
Answers:
Answers:
Answers:
Answers:
Answers:
Answers:
Answers:
Answers:
Answers:
Answers:
<?
echo 5 * 6 / 2 + 2 * 3;
?>
Answers:
Answers:
Answers:
- Use mysql_query() and variables: for example: $input = $_POST[‘user_input’]; mysql_query(“INSERT INTO table (column) VALUES (‘” . $input . “‘)”);
- 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));
- 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. “‘)”);
- 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. “‘)”);
Answers:
- mail($to,$subject,$body)
- sendmail($to,$subject,$body)
- mail(to,subject,body)
- sendmail(to,subject,body)
Answers:
- static
- global
- session_register()
- None of these
Answers:
- function_exists()
- has_function()
- $a = “function to check”; if ($a ()) // then function exists
- None of these
Answers:
- fclose
- fopen
- fwrite
- fgets
- fappend
Answers:
- A singleton pattern means that a class will only have a single method.
- A singleton pattern means that a class can have only one instance object.
- A singleton pattern means that a class has only a single member variable.
- Singletons cannot be implemented in PHP.
Answers:
- <
- >
- single quote
- double quote
- &
- All of these
Answers:
- $array_variable = get_object_vars($object);
- $array_variable = (array)$object;
- $array_variable = array $object;
- $array_variable = get_object_vars $object;
Answers:
- private $type = ‘moderate’;
- internal $term = 3;
- public $amnt = ‘500’;
- protected $name = ‘Quantas Private Limited’;
Answers:
- __FUNCTION__
- __TIME__
- __FILE__
- __NAMESPACE__
- __CLASS__
Answers:
- $e = new Exception; var_dump($e->debug());
- $e = new Exception; var_dump($e->getTraceAsString());
- $e = new Exception; var_dump($e->backtrace());
- $e = new Exception; var_dump($e->getString());
<?php
var_dump (3*4);
?>
Answers:
- int(3*4)
- int(12)
- 3*4
- 12
- None of the above
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.
Answers:
- s.sendmail($EmailAddress, [$MessageBody], msg.as_string())
- sendmail($EmailAddress, “Subject”, $MessageBody);
- mail($EmailAddress, “Subject”, $MessageBody);
- <a href=”mailto:$EmailAddress”>$MessageBody</a>
Answers:
- session(start);
- session();
- session_start();
- login_sesion();
<?php
function Expenses()
{
function Salary()
{
}
function Loan()
{
function Balance()
{
}
}
}
?>
Which of the following sequence will run successfully?
Answers:
- Expenses();Salary();Loan();Balance();
- Salary();Expenses();Loan();Balance();
- Expenses();Salary();Balance();Loan();
- Balance();Loan();Salary();Expenses();
Answers:
- multipart/form-data
- multipart
- file
- application/octect-stream
- None of these
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.
Answers:
- crypt()
- md5()
- sha1()
- bcrypt()
Answers:
- join_st
- implode
- connect
- make_array
- None of these
Answers:
- delete()
- delete_file()
- unlink()
- fdelete()
- file_unlink()
Answers:
- +
- ||
- .
- |||
- None of these
Answers:
- __call,__get,__set
- _get,_set,_load
- __get,__set,__load
- __overload
Answers:
- setcookie(“OrderCookie”,34);
- makeCookie(“OrderCookie”,34);
- Cookie(“OrderCookie”,34);
- OrderCookie(34);
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.
Answers:
- memory_limit = 128M
- limit_memory = 128M
- memory_limit: 128M
- limit_memory: 128M
Answers:
- $arr[$newkey] = $oldkey; unset($arr[$oldkey]);
- $arr[$newkey] = $arr[$oldkey]; unset($arr[$oldkey]);
- $newkey = $arr[$oldkey]; unset($arr[$oldkey]);
- $arr[$newkey] = $oldkey.GetValue(); unset($arr[$oldkey]);
<?
echo 5 * 6 / 2 + 2 * 3;
?>
Answers:
- 1
- 20
- 21
- 23
- 34
Answers:
- Yes
- No
No comments:
Post a Comment