Check Point Software PHP Interview Questions Answers

Check Point Software Most Frequently Asked Latest PHP Interview Questions Answers

What does the unset() function mean?

The unset() function is dedicated for variable management. It will make a variable undefined.

How do I escape data before storing it in the database?

The addslashes function enables us to escape data before storage into the database.

How is it possible to remove escape characters from a string?

The stripslashes function enables us to remove the escape characters before apostrophes in a string.

How can we automatically escape incoming data?

We have to enable the Magic quotes entry in the configuration file of PHP.

What does the function get_magic_quotes_gpc() means?

The function get_magic_quotes_gpc() tells us whether the magic quotes is switched on or no.

Is it possible to remove the HTML tags from data?

The strip_tags() function enables us to clean a string from the HTML tags.

what is the static variable in function useful for?

A static variable is defined within a function only the first time, and its value can be modified during function calls as follows:

<!--?php function testFunction() { static $testVariable = 1; echo $testVariable; $testVariable++; } testFunction();        //1 testFunction();        //2 testFunction();        //3 ?-->

How is it possible to cast types in PHP?

The name of the output type has to be specified in parentheses before the variable which is to be cast as follows:

* (int), (integer) - cast to integer

* (bool), (boolean) - cast to boolean

* (float), (double), (real) - cast to float

* (string) - cast to string

* (array) - cast to array

* (object) - cast to object

When is a conditional statement ended with endif?

When the original if was followed by: and then the code block without braces.
Check Point Software Most Frequently Asked Latest PHP Interview Questions Answers
Check Point Software Most Frequently Asked Latest PHP Interview Questions Answers

How is the ternary conditional operator used in PHP?

It is composed of three expressions: a condition, and two operands describing what instruction should be performed when the specified condition is true or false as follows:

Expression_1?Expression_2 : Expression_3;

What is the function func_num_args() used for?

The function func_num_args() is used to give the number of parameters passed into a function.

How can we define a variable accessible in functions of a PHP script?

This feature is possible using the global keyword.

How is it possible to return a value from a function?

A function returns a value using the instruction 'return $value;'.

What is the most convenient hashing method to be used to hash passwords?

It is preferable to use crypt() which natively supports several hashing algorithms or the function hash() which supports more variants than crypt() rather than using the common hashing algorithms such as md5, sha1 or sha256 because they are conceived to be fast. Hence, hashing passwords with these algorithms can create vulnerability.

what is the difference between for and foreach?

for is expressed as follows:

for (expr1; expr2; expr3)

statement

The first expression is executed once at the beginning. In each iteration, expr2 is evaluated. If it is TRUE, the loop continues, and the statements inside for are executed. If it evaluates to FALSE, the execution of the loop ends. expr3 is tested at the end of each iteration.

However, foreach provides an easy way to iterate over arrays, and it is only used with arrays and objects.

Explain how you can update Memcached when you make changes to PHP?

When PHP changes you can update Memcached by

Clearing the Cache proactively: Clearing the cache when an insert or update is made
Resetting the Cache: It is similar to the first method but rather than just deleting the keys and waiting for the next request for the data to refresh the cache, reset the values after the insert or update.

Which cryptographic extension provide generation and verification of digital signatures?

The PHP-OpenSSL extension provides several cryptographic operations including generation and verification of digital signatures.

How is a constant defined in a PHP script?

The define() directive lets us defining a constant as follows:

define ("ACONSTANT", 123);

How can you pass a variable by reference?

To be able to pass a variable by reference, we use an ampersand in front of it, as follows $var1 = &$var2

Will a comparison of an integer 12 and a string "13" work in PHP?

"13" and 12 can be compared in PHP since it casts everything to the integer type.

If the variable $var1 is set to 10 and the $var2 is set to the character var1, what's the value of $$var2?

$$var2 contains the value 10.

What does accessing a class via :: means?

:: is used to access static methods that do not require object initialization.

In PHP, objects are they passed by value or by reference?

In PHP, objects passed by value.

Are Parent constructors called implicitly inside a class constructor?

No, a parent constructor have to be called explicitly as follows:

parent::constructor($value)

What's the difference between __sleep and __wakeup?

__sleep returns the array of all the variables that need to be saved, while __wakeup retrieves them.

What is faster?

1- Combining two variables as follows:

$variable1 = 'Hello ';

$variable2 = 'World';

$variable3 = $variable1.$variable2;
Or

2- $variable3 = "$variable1$variable2";
$variable3 will contain "Hello World". The first code is faster than the second code especially for large large sets of data.

What does $_COOKIE mean?

$_COOKIE is an associative array of variables sent to the current PHP script using the HTTP Cookies.

Post a Comment

Previous Post Next Post