Certificação Flashcards
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.