Thursday, 20 March 2014

php interview question

Qsn. How to set cookies in PHP?
Ans.  Setcookie("sample", "ram", time()+3600);
in php we can use 5 parameters in setcookie and but in above e.g we used jsut 3 parameters.

Qsn. How to retrive cookies in PHP?
Ans. Echo $_COOKIE[user]";

Qsn. how to create a session in php?
Ans. the create syntax  session in php is :- SESSION_start();
and set a session value  in php :  $_session["user_id"];
Qsn. use of explode() function in php ?
Ans. Syntax of explode is :  array explode(string $delimiter , string $string[, int$limit]);
this is use for break a string into array.

Qsn. use of trim function in php?
Ans. use for remove white space and predefined character.

Qsn. how to redicect a page in php?
Ans.  Header("location:index.php"); this code is use for redirect any page;


No comments: