Suscriber with us



Receive HTML?

Syndicate

php interview question part1 PDF Print E-mail

1.What is AJAX?

Asynchronous JavaScript and XML, is a web development technique for creating interactive web applications. The intent is to make web pages feel more responsive by exchanging small amounts of data with the server behind the scenes, so that the entire web page does not have to be reloaded each time the user requests a change. This is meant to increase the web page's interactivity, speed, and usability.

The Ajax technique uses a combination of:

* XHTML (or HTML) and CSS, for marking up and styling information.
* The DOM accessed with a client-side scripting language, especially ECMAScript implementations such as JavaScript and JScript, to dynamically display and interact with the information presented.
* The XMLHttpRequest object is used to exchange data asynchronously with the web server. In some Ajax frameworks and in certain situations, an IFrame object is used instead of the XMLHttpRequest object to exchange data with the web server, and in other implementations, dynamically added <script> tags may be used.
* XML is sometimes used as the format for transferring data between the server and client, although any format will work, including preformatted HTML, plain text, JSON and even EBML. These files may be created dynamically by some form of server-side scripting.

Like DHTML, LAMP and SPA, Ajax is not a technology in itself, but a term that refers to the use of a group of technologies.

2.What is the defference between constructors in PHP4 & PHP5?

Constructors - PHP4

Constructors are functions in a class that are automatically called when you create a new instance of a class with new. A function becomes a constructor, when it has the same name as the class. If a class has no constructor, the constructor of the base class is being called, if it exists.


<?php
class Auto_Cart extends Cart {
function Auto_Cart() {
$this->add_item("10", 1);
}
}
?>

This defines a class Auto_Cart that is a Cart plus a constructor which initializes the cart with one item of article number "10" each time a new Auto_Cart is being made with "new". Constructors can take arguments and these arguments can be optional, which makes them much more useful. To be able to still use the class without parameters, all parameters to constructors should be made optional by providing default values.


void __construct ( [mixed args [, ...]] )

PHP 5 allows developers to declare constructor methods for classes. Classes which have a constructor method call this method on each newly-created object, so it is suitable for any initialization that the object may need before it is used.Parent constructors are not called implicitly if the child class defines a constructor. In order to run a parent constructor, a call to parent::__construct() within the child constructor is required.

3.What is meant by Exceptional Handling?

Exceptions
PHP 5 has an exception model similar to that of other programming languages. An exception can be thrown, try and caught within PHP. A Try block must include at least one catch block. Multiple catch blocks can be used to catch different classtypes; execution will continue after that last catch block defined in sequence. Exceptions can be thrown within catch blocks.
When an exception is thrown, code following the statement will not be executed and PHP will attempt to find the first matching catch block. If an exception is not caught a PHP Fatal Error will be issued with an Uncaught Exception message, unless there has been a handler defined with set_exception_handler().

4.What is meant by Virtual hosting?

Virtual hosting
HTTP includes the concept of virtual hosting, where a single HTTP server can represent multiple hosts at the same IP address.

A DNS server can allocate several different host names to the same IP address. When an HTTP client makes a request to a particular host, it uses the DNS server to locate the IP address corresponding to that host name, and sends the request to that IP address.

In HTTP/1.0 the host name did not appear in the HTTP message; it was lost after the IP address had been resolved. This meant that if more than one set of resources was held on the server represented by the IP address, the server would have difficulty distinguishing which resources belonged to which host.

However, HTTP/1.1 requests provide the host name in the request (usually in a Host header). The presence of the host name in the message enables the HTTP server to direct requests containing different host names to the appropriate resources for each host. This feature of HTTP is known as virtual hosting.

5.What is meant Session Clustering?

The Session Manager session support allows multiple server instances to share a common pool of sessions, known as a session cluster

Session clustering setting up methods :

#1)First methods, is to have a NFS shared where session will be store. Setting this is quite easy, just a little modification on php.ini file to change the “session.save_path ? directive to point to the NFS share. The main problem with NFS is on high traffic, NFS share is really slow. So synchronisation and data corruption can arrive and this can be very frustrating.
#2) The Second method is to use a Database to store session datas. This solution suppose to write custom session handler. The only real problem of this method is that will generate a very big amount of the number of connections and database query. And this required a dedicated server and a cron job to clean all unused session datas.
#3)The third method is to use the MCache. MCache is a daemon (a server) that deal with session storing only. It support from RAM storage to data serialization in file/fatabase. It is said that MCache access is native as a session handler in PHP, so it’s just about configuration via php.ini … but I did not investigate yet on how to make it work.
#4)The fourth method is Memcache, another daemon for “distributed memory object caching system ?. Advantage to Memcache, as it’s integrated in PHP as PECL (look at the documentation on how to install). This method can be very interesting as it provide great performance but this will require a single or couple dedicate server of it use.
#5)The last method is commercialized by Zend. The product is the Zend Platform and integrate many component of some previous Zend products (Zend Server, etc.) and some new products (Zend Core…). The Zend Core is a Cluster manager that can handle multiple server. It can be use to remote debugging (from Zend Server), performance monitoring and sessions replication. As described, there are many advantage using Zend Platform so I could only to advise you to use it simply first to profile your application and for session clustering ! But there are a little probleme, session are replicated from a server to the other servers. So if a server crash maybe the Platform could not have the time to replicate session data. It can result to session destruction. But be sure that Zend know the problem and will surely fix this soon or later.

6.How dose Database handle Sessions?

As you should be aware the HTTP protocol, as used for serving web pages, is completely stateless. This means that after the server has received a request, processed it and sent a response, the process which dealt with that request dies. Anything that the process had in its memory therefore dies with it, so when a subsequent request is received from the same client it is unable to refer to its memory about anything that happened previously.

Fortunately PHP provides a standard method of maintaining memory (state) between requests in the form of Session Handling functions. This allows the programmer to maintain a set of variables in the $_SESSION array which is automatically saved to persistent storage at the end of each script, and then automatically loaded back into memory when a subsequent request is received from a client which supplies the same session_id.

7.What is the difference between include and include_once?

include()

The include() statement includes and evaluates the specified file.
This also applies to require(). The two constructs are identical in every way except how they handle failure. include() produces a Warning while require() results in a Fatal Error. In other words, use require() if you want a missing file to halt processing of the page. include() does not behave this way, the script will continue regardless.

include_once()

The include_once() statement includes and evaluates the specified file during the execution of the script. This is a behavior similar to the include() statement, with the only difference being that if the code from a file has already been included, it will not be included again. As the name suggests, it will be included just once.

8.Tell me some thing about mod_rewrite and url rewriting?

mod_rewrite
*************

Simply, mod_rewrite is used for rewriting a URL at the server level, giving the user output for that final page. So, for example, a user may ask for http://www.referads.com/example/blue/, but will really be given http://www.referads.com/example.php?colour=blue by the server. Of course, the user will be none the wiser to this little bit of chicanery.

What do I need to get mod_rewrite working?
<?php phpinfo(); ?>

Load that page up in your web browser, and perform a search for “mod_rewrite”. All being well, you’ll find it in the “Apache loaded modules” section of the page. If it isn’t there, you’ll have to contact your hosting company and politely ask them to add it to the Apache configuration.

9.What are static methods?

Static Keyword
Declaring class members or methods as static makes them accessible without needing an instantiation of the class. A member declared as static can not be accessed with an instantiated class object (though a static method can).

The static declaration must be after the visibility declaration. For compatibility with PHP 4, if no visibility declaration is used, then the member or method will be treated as if it was declared as public.

Because static methods are callable without an instance of the object created, the pseudo variable $this is not available inside the method declared as static.

10.Which Storage Engine is the best and Why?

InnoDB

InnoDB provides MySQL with a transaction-safe (ACID compliant) storage engine with commit, rollback, and crash recovery capabilities. InnoDB does locking on the row level and also provides an Oracle-style consistent non-locking read in SELECT statements. These features increase multi-user concurrency and performance. There is no need for lock escalation in InnoDB because row-level locks in InnoDB fit in very little space. InnoDB also supports FOREIGN KEY constraints. In SQL queries you can freely mix InnoDB type tables with other table types of MySQL, even within the same query.

InnoDB has been designed for maximum performance when processing large data volumes. Its CPU efficiency is probably not matched by any other disk-based relational database engine.




Digg!Del.icio.us!Google!Live!Facebook!Slashdot!Technorati!StumbleUpon!Newsvine!Yahoo!Free social bookmarking plugins and extensions for Joomla! websites!
Last Updated ( Thursday, 13 March 2008 )
 
< Prev

Download Utility

XAMPP
WAMP
EditPlus
Zend Studio

Polls

Which is the best Scripting language?