Q1 : Who is the father of PHP and explain the changes in PHP versions?
A : Rasmus Lerdorf is known as the father of PHP.PHP/FI 2.0 is an early and no longer supported version of PHP. PHP 3 is the successor to PHP/FI 2.0 and is a lot nicer. PHP 4 is the current generation of PHP, which uses the Zend engine under the hood. PHP 5 uses Zend engine 2 which, among other things, offers many additionalOOP features
Q2 : What is SQL?
A : SQL stands for Structured Query Language. SQL is is a special-purpose programming language designed for data held in a relational database management system.
It’s originally based upon relational algebra and tuple relational calculus, It’s consists of a data definition language(DDL) and a data manipulation language(DML).
Q3 : How many type of sql joins?
A : MySQL supports the following types of joins:
- Cross join
- Inner join
- Left join
- Right join
Q4 : What is difference between TRUNCATE and DELETE in mysql
A : 1: DELETE is a DML(data manipulation lnguage) command whereas truncate is a DDL(data definition language) command.
2 : Truncate is much faster than Delete.
3 : We can not roll back in truncate but in delete we can rollback.
4 : We can not use where clause in truncate but in delete we can use conditions using where clause.
Q5 : What is difference between mysql_connect and mysql_pconnect
A : 1: While using the mysql_pconnect the function would try to find a connection that is already open with same host,username and password ie.(persistant connection) .If connection found an identifier will be returned instead of opening new connection. And with mysql_connect a new connection is always established .
2:While using mysql_pconnect the connection will not closed after the execution of script for future use and in mysql_connect the connection will automatically close when execution of script ends.
3 :mysql_pconnect uses less resources than mysql_connect.
Q6 : What is the difference between Mysql_fetch_object and Mysql_fetch_array?
A : mysql_fetch_object() is similar to mysql_fetch_array(), with one difference – an object is returned, instead of an array. Indirectly, that means that you can only access the data by the field names, and not by their offsets (numbers are illegal property names)
Q7 : How can I execute a Php Script using Command Line?
A : As of version 4.3.0, PHP supports a new SAPI type (Server Application Programming Interface) named CLI which means Command Line Interface. Just run the PHP CLI (Command Line Interface) program and provide the PHP script file name as the command line argument. For example, “php myScript.php”, assuming “php” is the command to invoke the CLI program.
Be aware that if your PHP script was written for the Web CGI interface, it may not execute properly in command line environment.
Q8 : What is the use of Friend Function?
A : Sometimes a function is best shared among a number of different classes. Such functions can be declared either as member functions of one class or as global functions. In either case they can be set to be friends of other classes, by using a friend specifier in the class that is admitting them. Such functions can use all attributes of the class which names them as a friend, as if they were themselves members of that class.
A friend declaration is essentially a prototype for a member function, but instead of requiring an implementation with the name of that class attached by the double colon syntax, a global function or member function of another class provides the match.
Q9 : Which MySQL Datatype should be used for storing boolean values
A : For MySQL 5.0.3 and higher, you can use BIT.
For versions lower than 5.0.3 you can use bool and boolean which are at the moment aliases of tinyint(1).
Q10 : How can we Register the Variables into a Session?
A : $_SESSION[’name’] = “Mizan”;
Q10 : What is heap table in MySQL
A : Tables that are present in memory is known as HEAP tables. When you create a heap table in MySQL,you should need to specify the TYPE as HEAP. These tables are commonly known as memory tables. They are used for high speed storage on temporary basis. They don’t allow BLOB or TEXT fields.
Q11 : What is difference between FLOAT and DOUBLE
A : FLOAT and DOUBLE both represents approximate numerical data values. MySql uses four bytes for single precision values and eight bytes for double precision values .
A Float is for single-precision value wheres DOUBLE is for double precision values and DOUBLE allows greater accurcy than FLOAT.
Float saves floating point numbers upto eight places and DOUBLE saves floating point numbers upto 18 places.
Q12 : What is the maximum size of a File that can be uploaded using Php and how can we change this?
A : By default the maximum size is 2MB. and we can change the following set up a php.iniupload_max_filesize = 2M
Q13 : How can we increase the Execution Time of a Php Script?
A : by changing the following set up a php.inimax_execution_time = 30 ; Maximum execution time of each script, in seconds.
Q14 :What is difference between PRIMARY key and UNIQUE Key in sql
A : 1: UNIQUE key can be a NULL value but PRIMARY key can not take NULL values.
2:A table can have multiple UNIQUE key but can only one PRIMARY key.
Q15 : How to get current date in MySql
A : SELECT CURRENT_DATE();
Q16 : What type of storage engine mysql support
A : Below are some storage engines names that a mysql support.
1 : MyISAM.
2 :InnoDB
3 :Memory
4 :CSV
5 :Merge etc.
Q17 : How can we optimize or increase the speed of a Mysql Select Query?
A :
- first of all instead of using select * from table1, use select column1, column2, column3.. from table1
- Look for the opportunity to introduce index in the table you are querying.
- use limit keyword if you are looking for any specific number of rows from the result set.
Q18 : How can we destroy the Cookie?
A : Set the cookie in past.
Q19 : What are the reasons for selecting Lamp (linux, Apache, Mysql, Php) instead of combination of other Software Programs, Servers and Operating Systems?
A : All of those are open source resource. Security of Linux is very very more than windows. Apache is a better server that IIS both in functionality and security. MySQL is world most popular open source database. PHP is more faster that asp or any other scripting language.
Q20 : In How many ways we can retrieve the data in the result set of Mysql using Php?
A : You can do it by 4 Ways
- mysql_fetch_row.
- mysql_fetch_array
- mysql_fetch_object
- mysql_fetch_assoc