Installing and using phpDocumentor on Ubuntu

phpDocumentor is a tool which creates complete documentation like Javadocs for PHP code.

Installing phpDocumentor

$ sudo apt-get libapache2-mod-php5

Restart Apache

$ sudo service apache2 restart

Install PEAR. PEAR is a repository of php extensions

$ sudo pear config-set data_dir /var/www

Tell PEAR where to install phpDocumentor

$ sudo pear install --alldeps phpDocumentor

www-data is user Apache on Ubuntu



Jar, War, and Ear files

.ear, .war, and .jar files are simply files zipped using Java jar tool. Each file is created for a different purpose:

.jar files
Jar (Java Archive) files contain libraries, resources and accessory files such as property files.

.war files
War (Web Archive) files contain web applications that can be deployed on any servlet/jsp container. It also contains other files required by the web application such as html, javascript, css, etc.

.ear files
Ear (Enterprise Archive) files contain EJB modules.



Java and Memory

From a programming point of view, there are essentially six different places to store data on your computer. The fastest storage is the registers since this memory resides inside the processor itself. No high-level language gives you direct access to this memory.



Java break and continue

Java’s break and continue statements are used to alter the flow of control.

break
The break statement can be used in for, while or do-while loops. It is also used in switch structure. A break statement exits the loop without executing the rest of the code in the loop. In other words, if the program encounters a break inside a for loop, it exits the loop without executing the remaining statements even if the test condition of the loop is still valid.

continue



Java - Null String

One problem that Java programmers often face is the string. If you use String.compareTo(), and one of the string is a null, you would get a NullPointerException. If you do Integer.parseInt(str), you would get a required: java.lang.String error. Obviously, you would want to check for a null string and/or avoid it.

Why do we get a NullPointerException?
Java Strings are objects, not primitives such as char or int. The java.lang.String class was created to make string manipulation easier.

char s[] = {'m', 'a', 'n'};



Java

Java is a high-level object-oriented programming language developed by Sun Microsystems. It is a vast languages and offers more than any other language in terms of functionality and richness of its core and libraries. It is an easy language to learn but difficult to master.

Here you will find some articles on Java.



Counting lines in a text file

The following simple code count the number of lines in a text file.

public function countLinesInTextFile($address)
{
    return count(file($address));
}
print countLinesInTextFile('file.txt');



Creating XML Document with DOM

As we go through the articles, we would be build a small library of functions which would prove to be very handy when you would start XML development.
php_dom_xml_library.php

function createFile()
{
    // create new dom document
    $xml = new DOMDocument();
    
    // save dom document to an xml file
    $xml->save('out.xml');
}

// call xml function
createFile();

output:

<?xml version="1.0"?>



XML DOM and PHP

XML is a markup language created to facilitate communication between different systems. Most implementations of XML serve to facilitate machine-to-machine communication.

Document Object Model (DOM) is an API which defines the logical structure and the ways to access and manipulate XML documents. XML presents data as documents. DOM is used to access and manipulate the data in XML documents.



PHP Error Logs

PHP errors are by default set to go to the apache error log. On Ubuntu, the error log is located at /var/log/apache2/error.log. If you are a PHP developer, it is good idea to open a small terminal window and type the following:

tail -f /var/log/apache2/error.log

This would essentially give you a live view of the error log. As you generate errors, you would see the error messages on the terminal.

Syndicate content