Certificação Flashcards
(52 cards)
AJax
AJAX is used to create more interactive applications. In AJAX, JavaScript sends the request to server, and the PHP script running in server responses.
Finally
finally
The code inside the finally block always executes regardless of whether an exception has been thrown or not.
Generator
A generator provides a simple mechanism to iterate through data without any need of writing a class implementing the Iterator interface.
Goto
The goto operator facilitates you to jump directly to a line of code within the same file.
Heredoc
In the heredoc string notation, a heredoc block starts with «< and then a block identifier.
Namespace
A namespace (sometimes also called a name scope) is an abstract container or environment created to hold a logical grouping of unique identifiers or symbols (i.e., names).
Yeld
This is a keyword that can be used in a function for both inputting and outputting data.
Which of the following enhances the performance of PHP by storing precompiled script bytecode in shared memory?
Opcache
Which of the following password hashing functions checks if the supplied hash implements the algorithm and options provided?
password_needs_rehash()
password_verify()
password_get_info()
password_hash()
password_needs_rehash()
Which of the following features in PHP allows creation of custom functions that retain the state between runs?
Array dereferencing
Generator
finally block
Resolution
Generator
Which of the following features is deprecated as of PHP 5.5?
namespace
curlwrappers
GD extension
OPcache extension
curlwrappers
Which of the following features is mainly used for writing cleanup code inside it?
try
catch
finally
yield
finally
Which of the following statements are true regarding the generators in PHP?
Each correct answer represents a complete solution. Choose all that apply.
Any function that contains a yield statement is a generator function.
Generator objects can be instantiated using the new keyword.
The empty() function can accept expressions as arguments.
The concept of generators was added in PHP version 5.3.
Answer options A and C are correct.
Any function that contains a yield statement is automatically a generator function. The empty() function can accept expressions as arguments. Generators allow you to create custom functions that retain the state between runs.
Answer options B and D are incorrect. The generator objects cannot be instantiated by using the new keyword. The concept of generators is added in PHP version 5.5.
function sampleFunction($val1, $val2, $ctr = 1) { for ($i = $val1; $i ; }
What will be the output?
1 3 5 7
1 7 2
1 3 5
3 5 7
A generator allows you to iterate over a set of data by using a foreach loop without building an array in memory. The output of the code will be:
1 3 5 7
namespace mynamespace { class myclass { function fun() { echo "Hello"; } } class studentClass { function studentRecord() { } } echo studentClass::class; }
mynamespace\myclass
mynamespace\studentClass
studentClass\studentRecord
Error
Answer option B is correct.
In PHP version 5.5, the class keyword can retrieve the fully qualified name of a class, including the namespace within which it has been defined. Therefore, the code snippet given in the question will print the name of the namespace and class.
Which of the following statements are true regarding an opcode cache?
Each correct answer represents a complete solution. Choose all that apply.
It speeds up the performance of PHP.
It slightly alters the behavior of applications negatively.
It overrides PHP’s default compiler callback.
It does not use shared memory for storage.
Answer options A and C are correct.
An opcode cache is mainly designed to speed up or enhance the performance of PHP without altering the behavior of applications. It overrides PHP’s default compiler callback. Before the advent of an opcode cache, each time you execute a .php file, it invokes a runtime compiler, generates an in-memory representation of the file, which is known as intermediate code, and then invokes the executor on it.
Answer options B, and D are incorrect. An opcode cache does not alter the behavior of applications negatively. The modern opcode caches use shared memory for storage.
Which of the following are the newly added features in PHP 5.5?
Each correct answer represents a complete solution. Choose all that apply.
try-catch
Generators
finally keyword
yield keyword
Answer options B, C, and D are correct.
Some of the newly added features in PHP 5.5 are: Generators: A generator provides a simple mechanism to iterate through data without any need of writing a class implementing the Iterator interface. finally: This version of PHP supports the finally block after the try-catch block. The code inside the finally block will always execute regardless of whether an exception has been thrown or not. yield: The keyword 'yield' can be used in a function for both inputting and outputting data. The concept of generator is mainly implemented by this keyword. Answer option A is incorrect. The try-catch block was available in previous versions as well.
Which of the following statements is true regarding a script?
A program that is interpreted directly by a microprocessor
A program developed by using JVM
A program that can be interpreted only by a web server
A program that is interpreted by another program
Answer option D is correct.
A script is a program or a sequence of instructions, which is interpreted by another program.
Answer options C, A, and B are incorrect. This is not true that a script can only be interpreted by a web server only. The Java programs are developed using JVM. The scripts are invisible to users but they are available to respond on user’s actions. The behavior of a web application depends upon the scripts. Every script represents a text document that contains a list of instructions that are executed by a program or scripting manager so that the desired and required actions could be achieved automatically.
echo (int) ((0.1 + 0.7) * 10);
What will be the output of the PHP script?
7
8
The PHP script will return an error message.
10
The expression ((0.1 + 0.7) * 10) will evaluate to 8. However, PHP stores the value of the expression internally as fractional value such as 7.999999 instead of 8. Here we are typecasting the value of expression into integer. When fractional values are type casted to integer value, the PHP truncates the fractional part (result have significant error of 12.5%, to be exact). Hence above expression will give 7 as output.
Hence = Daí
Which of the following operators is known as the error control operator in PHP?
is known = é conhecido
The symbol (@) in PHP is known as the error control operator. In PHP, when it is prepended to an expression, then any error messages generated by that expression will be ignored.
Which of the following statements are true regarding constants and variables?
regarding = em relacao à
Each correct answer represents a complete solution. Choose all that apply.
The name of a variable and constant starts with a $ sign.
A constant can be defined by using the const_define() method.
A constant can be defined and accessed anywhere regardless of variable scoping rules.
The value of a constant cannot be redefined once they have been set.
Answer options C and D are correct.
A constant can be defined and accessed anywhere regardless of variable scoping rules. The value of a constant cannot be redefined or undefined once they have been set.
Answer options A, and B are incorrect. There is no need to write a dollar sign ($) before a constant; however, in case of a variable, you have to write a dollar sign. A constant can be defined by using the define() method.
Which of the following are valid PHP variables?
Each correct answer represents a complete solution. Choose three.
$variable
${0x0}
&$variable
$0x0
Answer options C, B, and A are correct.
&$variable, ${0x0}, and $variable are valid variables. A valid php variable starts with a dollar($) symbol followed by the variable name. The name of the variable must begin with a letter or an underscore. In php, you can also ‘assign by reference’ values to a variable. For this, you can prefix a variable to be assigned by an assignment operator.
&$variable has a the ‘&’ reference operator attached to it. It references to the variable $variable. So it is a valid php variable.
${0x0} uses a valid curly braces syntax. Anything inside {} will be interpolated. So 0x0 will be interpolated to 0 and stored as a variable with the name 0. So it is a valid php variable.
$variable begins with a valid dollar ($) symbol with the variable name as ‘variable’. So it is a valid php variable.
Answer option D is incorrect. $0x0 is not a valid option because variables do not begin with numbers.
Which of the following data types are compound data types?
compound = composto
Answer options C and B are correct.
Arrays and objects are compound data types. Arrays are data types that contain ordered data elements. An array can be used to store and retrieve any other data type, such as numbers, Boolean values, strings, objects, and even other arrays. Objects are data types that contain both data and code.
Answer options A and D are incorrect. Booleans and strings are scalar data types. Booleans are data types that contain only two values:
true
false
Strings are ordered collections of binary data, such as text, contents of an image file, spreadsheet, etc.
Which of the following is a PHP accelerator used for increasing the speed of PHP applications running on Windows and Windows Server?
File Cache
Windows Cache Extension
BLOB
PHP opcode cache
Answer option B is correct.
Windows Cache Extension is a PHP accelerator used for increasing the speed of PHP applications running on Windows and Windows Server.
Answer option A is incorrect. A file cache stores the content of the PHP script files in shared memory which in turn decreases the amount of the file system operations that is performed by the PHP engine.
Answer option D is incorrect. PHP opcode cache stores the compiled script bytecode in shared memory. In return, it is reused by the PHP engine for subsequent executions of the same script.
Answer option C is incorrect. A BLOB (Binary Large Object) can be defined as a collection of binary data that gets stored as a single entity in a database management system.