What is the use of ini_set() ?

Entry

PHP allows the user to modify some of its settings mentioned in php.ini using ini_set(). This function requires two string arguments. The first one is the name of the setting to be modified and the second one is the new value to be assigned to it.

Given line of code will enable the display_error setting for the script if it’s disabled.

ini_set('display_errors', '1');

We need to put the above statement, at the top of the script so that, the setting remains enabled till the end. Also, the values set via ini_set() are applicable, only to the current script. Thereafter, PHP will start using the original values from php.ini.

What is the difference between == and ===?

Entry
  • The operator == casts between two different types if they are different

  • The === operator performs a 'typesafe comparison'

That means that it will only return true if both operands have the same type and value.

1 === 1: true
1 == 1: true
1 === "1": false // 1 is an integer, "1" is a string
1 == "1": true // "1" gets casted to an integer, which is 1
"foo" === "foo": true // both operands are strings and have the same value

What is the return type of a function that doesn't return anything?

Entry

void which means nothing.

What is the purpose of the php.ini file?

Entry

The PHP configuration file, php.ini, is the final and most immediate way to affect PHP's functionality. The php.ini file is read each time PHP is initialized. in other words, whenever httpd is restarted for the module version or with each script execution for the CGI version.

What are the keys & values in an indexed array?

Entry

Consider:

Array ( [0] => Hello [1] => world [2] => It's [3] => a [4] => beautiful [5] => day)

The keys of an indexed array are 0, 1, 2 etc. (the index values) and values are "Hello", "world", "It's", "beautiful", "day".

What does $GLOBALS mean?

Entry

$GLOBALS is associative array including references to all variables which are currently defined in the global scope of the script.

How can you pass a variable by reference in Php?

Entry

To be able to pass a variable by reference, we use an ampersand in front of it, as follows:

$var1 = &$var2

Login to Unlock Full Access

Create ProTechStack account To Unlock 1000+ Expert Questions, Jobs & Much More