181⟩ How will you unset a single session variable?
Here is the example to unset a single variable −
<?php
unset($_SESSION['counter']);
?>
“Sr. PHP Programmer based Frequently Asked Questions by expert members with experience as Senior PHP Programmer. These questions and answers will help you strengthen your technical skills, prepare for the new job test and quickly revise the concepts”
Here is the example to unset a single variable −
<?php
unset($_SESSION['counter']);
?>
Common uses of PHP −
☛ PHP performs system functions, i.e. from files on a system it can create, open, read, write, and close them.
☛ PHP can handle forms, i.e. gather data from files, save data to a file, thru email you can send data, return data to the user.
☛ You add, delete, modify elements within your database thru PHP.
☛ Access cookies variables and set cookies.
☛ Using PHP, you can restrict users to access some pages of your website.
☛ It can encrypt data.
No. You should understand what multiple inheritance is.
To concatenate two string variables together, use the dot (.) operator −
<?php
$string1="Global Guideline";
$string2="Interviews";
echo $string1 . " " . $string2;
?>
This will produce following result:
Global Guideline Interviews
The count() function is used to return the number of elements in an array.
Understanding of arrays and array related helper functions it's a knowledge that every junior developer should have.
The PHP rand() function is used to generate a random number. This function can generate numbers with-in a given range. The random number generator should be seeded to prevent a regular pattern of numbers being generated. This is achieved using the srand() function that specifies the seed number as its argument.
File's existence can be confirmed using file_exist() function which takes file name as an argument.
A PHP session is easily started by making a call to the session_start() function.This function first checks if a session is already started and if none is started then it starts one. It is recommended to put the call to session_start() at the beginning of the page.
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. If your change isn.t showing up, remember to stop and restart httpd. If it still isn.t showing up, use phpinfo() to check the path to php.ini.
To delete a cookie you should call setcookie() with the name argument only.
The PHP fopen() function is used to open a file. It requires two arguments stating first the file name and then mode in which to operate. "r" mode opens the file for reading only and places the file pointer at the beginning of the file.
This is a global PHP variable. This variable is an associate double dimension array and keeps all the information related to uploaded file.
array() − Creates an array.
Whitespace is the stuff you type that is typically invisible on the screen, including spaces, tabs, and carriage returns (end-of-line characters). PHP whitespace insensitive means that it almost never matters how many whitespace characters you have in a row.one whitespace character is the same as many such characters.
Associative array − An array with strings as index. This stores element values in association with key values rather than in a strict linear index order.
PHP provides a large number of predefined constants to any script which it runs known as magic constants.
_LINE_ − The current line number of the file.
The PHP $_REQUEST variable contains the contents of both $_GET, $_POST, and $_COOKIE. We will discuss $_COOKIE variable when we will explain about cookies. The PHP $_REQUEST variable can be used to get the result from form data sent with both the GET and POST methods.
Yes! You can set a parameter to have a default value if the function's caller doesn't pass it.
_METHOD_ − The class method name. (Added in PHP 5.0.0) The method name is returned as it was declared (case-sensitive).