In the PHP world, namespaces are designed to solve two problems that authors of libraries and applications encounter when creating re-usable code elements such as classes or functions:
- Name collisions between code you create, and internal PHP classes/functions/constants or third-party classes/functions/constants.
- Ability to alias (or shorten) Extra_Long_Names designed to alleviate the first problem, improving readability of source code.
PHP Namespaces provide a way in which to group related classes, interfaces, functions and constants.
6 ) What are the types of inheritance PHP supports ?
Ans:
Similar to Java, PHP supports single inheritance. There is no multiple inheritance in php. Single inheritance means a class can extend only one parent class.
PHP also has interfaces which can be implemented if bunch of classes need to have similar functionality. An interface can be created containing methods with empty body. Implementing classes then must provide body to those methods.
When a class implements an interface, it is signing up a contract that it will provide implementation to methods declared in that interface.
7 ) What do you mean by an Abstract class and Interface ?
Ans:
Depending on the context, an interface class is either a class of the interface layer or a class whose purpose is to create a contract between a caller and an implementation (usually by providing only purely virtual functions).
An abstract class is a class that has at least one purely virtual function. Abstract classes can contain abstract and concrete methods. Abstract classes cannot be instantiated directly i.e. we cannot call the constructor of an abstract class directly nor we can create an instance of an abstract class
A static class is a class that has only static member variables and static member functions.
8 ) When a file is uploaded to the sever how can you check whether its uploaded or not ?
Ans:
(PHP 4 >= 4.0.3, PHP 5)
is_uploaded_file — Tells whether the file was uploaded via HTTP POST.
is_uploaded_file($_FILES['userfile']['tmp_name']);
Returns TRUE on success or FALSE on failure.
9 ) How will you move the uploaded file to another location of server ?
Ans:
move_uploaded_file — Moves an uploaded file to a new location.
This function checks to ensure that the file designated by filename is a valid upload file (meaning that it was uploaded via PHP's HTTP POST upload mechanism).
If the file is valid, it will be moved to the filename given by destination.
10 ) What are the things that need to be checked before uploading a file ?
Ans:
Check picture file type and size before file upload..
more details:
11 ) How will you connect mysql ?
Ans: Here u can get Click Here
12 ) Does PHP supports PDF creation ?
Ans:
The PDF functions in PHP can create PDF files using the PDFlib library which was initially created by Thomas Merz and is now maintained by » PDFlib GmbH.
Starting with PHP 4.0.5, the PHP extension for PDFlib is officially supported by PDFlib GmbH. This means that all the functions described in the PDFlib Reference Manual are supported by PHP 4 with exactly the same meaning and the same parameters.
13 ) What are the storage types in MySQL ?
Ans:
13.1. The MyISAM Storage Engine[default engine]
13.2. The InnoDB Storage Engine
13.3. The MERGE Storage Engine
13.4. The MEMORY (HEAP) Storage Engine
13.5. The BDB (BerkeleyDB) Storage Engine
13.6. The EXAMPLE Storage Engine
13.7. The FEDERATED Storage Engine
13.8. The ARCHIVE Storage Engine
13.9. The CSV Storage Engine
13.10. The BLACKHOLE Storage Engine
more details
14 ) What is the difference between InnoDb and MyISAM ?
Ans:
- The big difference between MySQL Table Type MyISAM and InnoDB is that InnoDB supports transaction
- InnoDB supports some newer features: Transactions, row-level locking, foreign keys
- InnoDB is for high volume, high performance
15 ) Does MyISAM supports relations ?
Ans: InnoDB has foreign keys and relationship contraints while MyISAM does not.
more details
16 ) What’s indexing ?
Ans:
A database index is a data structure that improves the speed of data retrieval operations on a database table at the cost of slower writes and increased storage space.
17 ) MySQL is case sensitive or case insensitive ?
Ans:
SQL itself isn't case sensitive, but it can be on searching data, all depends on the table collation settings.
MySQL syntax is not case sensitive, you can write
SELECT * FROM table WHERE ...
or
select * from table where...
or
SeLEct * FroM table WHerE
or whatever else you want.
On select queries you can search for case sensitive fields values, in example if you want to find "text" inside a field but not "TEXT", "Text".... you can use
SELECT * FROM table WHERE binary(fieldname)='text';
18 ) You have a table say user with field name and data’s Lokam , loker , lover , Lough , Lost , Enough , Elephant etc . Write a query which gives all the terms Lokam , loker , lover , Lough and Lost .
Ans: SELECT * FROM `user` WHERE `name` LIKE 'lo%' ;
any questions ask me in comments...
19 ) Now you want to select only the loker , lover . What will you add to get this result ?
Ans: SELECT * FROM `user` WHERE `name` LIKE 'lo%er' ;
any questions ask me in comments...
20 ) Let there is table user with name and marks . How will you select the second largest number from this table ? For eg let the data’s are
hari 23 , jenson 10 , ruby 20 , rijith 10 . You want to select 20 from this.
Ans:
SELECT * FROM user WHERE marks = (SELECT MAX(marks) FROM user WHERE marks < (SELECT MAX(marks) FROM user)) ORDER BY marks DESC LIMIT 0,1
any questions ask me in comments...
21 ) What are the different types of JOINS ?
Ans:
A join combines records from two or more tables in a relational database. In the Structured Query Language (SQL), there are two types of joins: "inner" and "outer". Outer joins are subdivided further into left outer joins, right outer joins, and full outer joins.
Inner join
This is the default join method if nothing else is specified. An inner join essentially finds the intersection between the two tables. The join takes all the records from table A and finds the matching record(s) from table B. If no match is found, the record from A is not included in the results. If multiple results are found in B that match the predicate then one row will be returned for each (the values from A will be repeated).
Special care must be taken when joining tables on columns that can be NULL since NULL values will never match each other
Left outer join
A left outer join is very different from an inner join. Instead of limiting results to those in both tables, it limits results to those in the "left" table (A). This means that if the ON clause matches 0 records in B, a row in the result will still be returned—but with NULL values for each column from B.
Right outer join
A right outer join is much like a left outer join, except that the tables are reversed. Every record from the right side, B, will be returned, and NULL values will be returned for those that have no matching record in A.
Full outer join
Full outer joins are the combination of left and right outer joins. These joins will show records from both tables, and fill in NULLs for missing matches on either side
23 ) Have you used Triggers ? What is it ?
Ans:
A database trigger is procedural code that is automatically executed in response to certain events on a particular table or view in a database.
The trigger is mostly used for keeping the integrity of the information on the database.
For example, when a new record (representing a new worker) is added to the employees table, new records should be created also in the tables of the taxes, vacations, and salaries.
24 ) What is Views in MySQL ?
Ans:
A database View is known as a "virtual table" which allows you to query the data in it.
Understanding Database View and using it correctly is crucial.
MySQL views are essentially a way to package up SELECT statements into re-usable virtual tables whereby the data can be retrieved simply by referencing the view, rather than having to repeat the associated SELECT statement.
26 ) How can you call a mysql procedure from PHP ?
Ans: Read all links of ans 25.
29 ) What’s SOAP ?
Ans:
SOAP, originally defined as Simple Object Access Protocol, is a protocol specification for exchanging structured information in the implementation of Web Services in computer networks.
It relies on Extensible Markup Language (XML) for its message format, and usually relies on other Application Layer protocols, most notably Hypertext Transfer Protocol(HTTP) and Simple Mail Transfer Protocol (SMTP), for message negotiation and transmission. SOAP can form the foundation layer of a web services protocol stack, providing a basic messaging framework upon which web services can be built.
30 ) What’s is XSS attack ?
Ans:
Cross-site scripting (XSS) is a type of computer security vulnerability typically found in Web applications that enables attackers to inject client-side script into Web pages viewed by other users.
A cross-site scripting vulnerability may be used by attackers to bypass access controls such as the same origin policy.
33 ) What’s the difference between session_register and $_SESSION ?
Ans:
The very first main and simple difference is that session_register function returns boolean value and $_SESSION returns string value.
The second will be session_register function doesn't work if register_global is disabled.
But whereas $_SESSION works in both case whether register_global is disabled or enabled. So using $_SESSION for session variable manipulation is more appropriate.
34 ) What is magic quotes ? Is it on or off by default in PHP 5 ?
Ans:
Magic Quotes is a process that automagically escapes incoming data to the PHP script.
It's preferred to code with magic quotes off and to instead escape the data at runtime, as needed.
Magic Quotes are depreciated and going to be removed in PHP6.
You can submit a form without a submit button, but it relies on javascript, which is a bad thing. How will you keep your pages working for those without javascript enabled?
Anyway, to submit the first form on your page, you can use something like this:
on link onclick="document.forms[0].submit();"
submit
37 ) How can you set a cookie to expire after 30 minutes or so ?
Ans:
30 minutes is 30 * 60 * 1000
miliseconds. Add that to the current date to specify an expiration date 30 minutes in the future.
var date = new Date();
date.setTime(date.getTime() + (30 * 60 * 1000));
$.cookie("example", "foo", { expires: date });
and for session>>
if(isSet($_SESSION['started'])){
if((mktime() - $_SESSION['started'] - 60*30) > 0){
//logout, destroy session etc
}
}else{
$_SESSION['started'] = mktime();
}
--
Thank You
Nelson Desai