What are the Technology to Use for Parsing the XML ?
There are two types of XML parsers the we can use.
1. DOM (Document Object Module).
2. SAX (Simple API for XML).
The DOM (Document Object Model) extension allows to operate on XML documents through the DOM API with PHP 5. DOM is a standard defined by the W3C for accessing XML documents.
In PHP 4, DOM xml extension is not following the standard method names.
As per the new W3C compatibility, the old dom fxml-based scripts won’t work anymore. The API is quite different in PHP 5. But if we used the “almost W3C compatible” method names available in PHP 4.3, We only need to change the loading and saving methods, and remove the underscore in the method names. Other adjustments here and there may be necessary, but the main logic can stay the same. Though we have not used earlier so these will not be a problem for us.
The easiest way to read a well-formed XML file is to use the DOM library . The DOM library reads the entire XML document into an object and represents it as a tree of nodes,
SAX stands for Simple API for XML. It’s a callback-based interface for parsing XML documents. SAX support has been available since PHP 3 and hasn’t changed a lot since then. For PHP 5 the API is unchanged, The only difference is that it’s not based on the expat library anymore, but on the libxml2 library.
Rather than treating an XML document as a tree-like structure, SAX treats it as a series of events such as startDocument or endElement. To accomplish this, a SAX appllication consists of a parser that sends these events to “handlers,” methods or functions designated to handle them.
If you need a superfast forward only XML parser, you can use XMLReader. However you probably don\’t want a forward only parser.
If you want to read data from an XML file, the simple XML extension is probably the nicest solution. Also for creating XML, it might work well for you. Have a look at this article: http://devzone.zend.com/node/view/id/688
If you want a superfast forward only XML writer, use XMLWriter. You could also do this by just outputting the XML of sticking it all together in a string. But the XMLWriter will make your code clearer, automatically escape stuff and give some error indications.
How can we get second of the current time using date function? what is Magic methods in php?
There are seven special methods, and they are as follows:
__construct( ) Called when instantiating an object
__destruct( ) Called when deleting an object
__get( ) Called when reading from a nonexistent property
__set( ) Called when writing to a nonexistent property
__call( ) Called when invoking a nonexistent method
__toString( ) Called when printing an object (for eg: converting an object to strings)
__clone( ) Called when cloning an object (copying object)
There are actually 12 special methods at last count
The function names __construct, __destruct (see Constructors and Destructors), __call, __get, __set, __isset, __unset (see Overloading), __sleep, __wakeup, __toString, __set_state and __clone
what is scandir() ?
List files and directories inside the specified path By default files order will be ascending
$f = scandir($direct, 1); it will display the files as descending order
Which types of form elements can be excluded from the HTTP request?
A. text, radio, and check box
B. text, submit, and hidden
C. submit and hidden
D. radio and check box
Answer D is correct.
When not selected, both radio buttons and check boxes are excluded from the HTTP request. Answer A, C, B are incorrect because they are always included in the request.
Is PHP a case sensitive programming language?
PHP is a partially case sensitive programming language. We can use function names, class names in case insensitive manner.
What is mean by LAMP?
LAMP means combination of Linux, Apache, MySQL and PHP.
How do you get the user’s ip address in PHP?
Using the server variable: $_SERVER[’REMOTE_ADDR’]
What is the difference between require and include?
When using require function to embed another file in php, it will give fatal error if the file is not exists.
When using include function to embed another file in php, it will give warning if the file is not exists.
How to find the number of elements in an array?
Using count($array) or sizeof($array).
How do you make one way encryption for your passwords in PHP?
Using md5 function or sha1 function
How do you get ASCII value of a character?
By using ord function.