How can we destroy the session, how can we unset the variable of a session?How can we extract string 'abc.com ' from a string http://info@abc.com using regular expression of php?How can we extract string "abc.com" from a string "mailto:info@abc.com ?subject= Feedback" using regular expression of PHP?What are the different functions in sorting an array?How To Read the Entire File into a Single String?How To Turn On the Session Support?How can we create a database using PHP and MySQL ? ~ Interview Questions & Answers
6:26 PM
session_unset() function frees all session variables currently registered.
If $_SESSION (or $HTTP_SESSION_VARS for PHP 4.0.6 or less) is used, use unset() to unregister a session variable.
i.e. unset ($_SESSION['varname']);.
6:29 PM
We can use the preg_match() function with "/.*@(.*)$/" as the regular expression pattern.
For example:
preg_match("/.*@(.*)$/","http://info@abc.com",$data);
echo $data[1];
6:28 PM
$text = "mailto:info@abc.com?subject=Feedback";
preg_match('|.*@([^?]*)|', $text, $output);
echo $output[1];
Note that the second index of $output, $output[1], gives the match, not the first one, $output[0].
Array sorting functions in PHP:
asort()
arsort()
ksort()
krsort()
uksort()
sort()
natsort()
rsort()
6:15 PM
If you have a file, and you want to read the entire file into a single string, you can use the file_get_contents() function. It opens the specified file, reads all characters in the file, and returns them in a single string.
6:18 PM
The session support can be turned on automatically at the site level, or manually in each PHP page script:
* Turning on session support automatically at the site level: Set session.auto_start = 1 in php.ini.
* Turning on session support manually in each page script: Call session_start() function.
6:23 PM
We can create MySQL database with the use of mysql_create_db($databaseName) to create a database.