Chapter 38. Integrating PHP and Java

The relationship between PHP and Java has changed significantly with each new release. Unsurprisingly, given the source code, PHP initially had much more in common with C. PHP4 supported integration of PHP and Java using a Java servlet environment or, more experimentally, directly into PHP. Finally, with the overhaul of the object model in PHP5, there was a distinctly Java feel to the PHP approach to object-oriented programming. Java users will find the improved object model in PHP6 very familiar, although there are important differences.

Given these changes, as PHP takes on a more Java-like cast, there are two possibilities for which a discussion of PHP and Java might be pertinent. You might need to work on a project that requires PHP and Java or Java Server Pages (JSP) to work in tandem. Or you may be approaching PHP from a Java background and want to know about the similarities and differences in order to learn PHP faster. We will deal with both needs in this chapter.

If you don't have a need to use Java, or aren't already familiar with the language, this chapter won't do much for you.

PHP for Java programmers

Most projects won't require integration of Java and PHP, unless there is some specific need due to preexisting architecture. The Java programmer approaching PHP for the first time ...

Get PHP6 and MySQL® 6 Bible now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.