200-550 無料問題集「Zend-Technologies Zend Certified PHP Engineer」
Is the following code vulnerable to SQL Injection ($mysqli is an instance of the MySQLi class)?
$age = $mysqli->real_escape_string($_GET['age']);
$name = $mysqli->real_escape_string($_GET['name']);
$query = "SELECT * FROM `table` WHERE name LIKE '$name' AND age = $age";
$results = $mysqli->query($query);
$age = $mysqli->real_escape_string($_GET['age']);
$name = $mysqli->real_escape_string($_GET['name']);
$query = "SELECT * FROM `table` WHERE name LIKE '$name' AND age = $age";
$results = $mysqli->query($query);
正解:D
解答を投票する
CORRECT TEXT
Which DOMElement property provides a reference to the list of the element's children?
Which DOMElement property provides a reference to the list of the element's children?
正解:
childNodes
CORRECT TEXT
Please provide the value of the $code variable in the following statement to set an HTTP status code that signifies that the requested resource was not found.
http_response_code($code);
Please provide the value of the $code variable in the following statement to set an HTTP status code that signifies that the requested resource was not found.
http_response_code($code);
正解:
404, 404 Not Found
CORRECT TEXT
What is the output of the following code?
function increment ($val) {
$_GET['m'] = (int) $_GET['m'] + 1; }
$_GET['m'] = 1;
echo $_GET['m'];
What is the output of the following code?
function increment ($val) {
$_GET['m'] = (int) $_GET['m'] + 1; }
$_GET['m'] = 1;
echo $_GET['m'];
正解:
1
Consider the following table data and PHP code. What is the outcome?
Table data (table name "users" with primary key "id"):
id name email
1 anna [email protected] 2 betty [email protected] 3 clara [email protected] 5 sue [email protected]
PHP code (assume the PDO connection is correctly established):
$dsn = 'mysql:host=localhost;dbname=exam';
$user = 'username';
$pass = '********';
$pdo = new PDO($dsn, $user, $pass);
try {
$cmd = "INSERT INTO users (id, name, email) VALUES (:id, :name, :email)";
$stmt = $pdo->prepare($cmd);
$stmt->bindValue('id', 1);
$stmt->bindValue('name', 'anna');
$stmt->bindValue('email', '[email protected]');
$stmt->execute();
echo "Success!";
} catch (PDOException $e) {
echo "Failure!";
throw $e;
}
Table data (table name "users" with primary key "id"):
id name email
1 anna [email protected] 2 betty [email protected] 3 clara [email protected] 5 sue [email protected]
PHP code (assume the PDO connection is correctly established):
$dsn = 'mysql:host=localhost;dbname=exam';
$user = 'username';
$pass = '********';
$pdo = new PDO($dsn, $user, $pass);
try {
$cmd = "INSERT INTO users (id, name, email) VALUES (:id, :name, :email)";
$stmt = $pdo->prepare($cmd);
$stmt->bindValue('id', 1);
$stmt->bindValue('name', 'anna');
$stmt->bindValue('email', '[email protected]');
$stmt->execute();
echo "Success!";
} catch (PDOException $e) {
echo "Failure!";
throw $e;
}
正解:A
解答を投票する