Header menu

_________________________________________________________________________________

Friday, 24 January 2014

Set a cookie / Use a cookie / Discuss a cookie / Explain Cookie


How to set a cookie.

Use setcookie() for setting a cookie.

Example : setcookie('flavor','vanilla');

Calling setcookie()

Cookies are sent with the HTTP headers, so setcookie() must be called before any output is generated. 

Use a Cookie

<?php
// Print an individual cookie
echo $_COOKIE["flavor"]; ?>
 


Arguments to setcookie()

You can pass additional arguments to setcookie() to control cookie behavior. The third argument to setcookie() is an expiration time,expressed as an epoch time- stamp.

Example setcookie('flavor','vanilla',1202075201);

Sunday, 19 January 2014

Best collection of php interview questions with answer for freshers


ANY SUGGESTION , QUESTION or CORRECTION is heartly welcome ... 


Ques 1. How can I disable the output of error message inside a HTML page?

Ans. Use  error_reporting(0);  to hide the error message in output.


Ques.2 Can we return other file formats (like Word, Excel, etc) using PHP script?

Ans. Yes we can create and return file formats(like Word, Excel etc) using php script.


Ques.3 Why we use session variable ?

Ans.  When we work on an application, we open it, do our stuff and then we close it. This is much like a (time interval)Session. The computer knows who we are. It knows when we started the application and when we ended it. But on the internet there is a problem,  web server does not know who we are and what we do. Because the HTTP address does not maintain state.
A PHP session solves this problem by allowing us to store user information on the server for later use (i.e. username, place,email id etc). However, session information is temporary and will be deleted as soon as the user has left the website. If we need a permanent storage then we have to store the data in a database.


Ques.4 Explain PEAR in php ?

Saturday, 18 January 2014

How to get my ubuntu version ?

To know which version of ubuntu you are using , you can use two ways :-

1. Using Terminal

2. Using Interface

Using Terminal

To know your ubuntu version through terminal use lsb_release -a


Using Interface

To know  your ubuntu version using interface first click on system setting from top right corner of the desktop


then after click on details ..


Friday, 17 January 2014

Difference between various types of join in SQL


Assuming you're joining on columns with no duplicates, this the most common case:
  • An inner join of table One and Two gives the result of One intersect Two, i.e. the inner part of a venn diagram intersection.
  • An outer join of One and Two gives the results of One union Two, i.e. the outer parts of a venn diagram union.

Examples
Suppose you have two Tables, with a single column each, and data as follows:
One     Two
-     -
1     3
2     4
3     5
4     6

Note that (1,2) are unique to One, (3,4) are common, and (5,6) are unique to Two.


Inner join
An inner join using either of the equivalent queries gives the intersection of the two tables, i.e. the two rows they have in common.
select * from One INNER JOIN Two on One.One = Two.Two;


One  | Two

3  | 3
4  | 4

Wednesday, 15 January 2014

Explain difference between include , require and require_once in php ?


To include the content of a PHP file into another PHP file before the server executes it. There are three PHP functions which can be used to include one PHP file into another PHP file.
  • The include() Function 
  • The require() Function
  • The require_once() Function
These functions helps in creating functions, headers, footers, or elements that can be reused on multiple pages. This help developers to change the layout of complete website with minimal effort. If there is any change needed then instead of making change in large numbers of files just change included file.

The include() Function

The include() function copies all text from file which is passed as parameter into the file that uses the include function. If there is any problem in loading thefile then the include() function generates a warning but the script will continue execution.