Chances are you will encounter various minor problems when you first attempt to integrate Java and PHP functionality, particularly if you are a relative newcomer to the Java programming environment. Even if the Java code compiles correctly, you may still encounter problems, largely due to differences found between the two languages.

two of these differences here:

Data types

PHP is a loosely-typed language, which means it is rather lenient on the way variables are used. On the contrary, Java is a strongly-typed language, which means that its policies for handling variables and data types are rather stringent. To illustrate the problem this difference poses, take a moment to again review the code. Notice that I had to typecast the $price and $tax variables before passing them to the SalesTax() method, because this method requires that both input parameters are of type "double." If this is not done, then input such as 24 for price would cause an error to occur.

Furthermore, if you are not adamant in ensuring the correct data types are passed to the Java methods, you may receive unexpected results, although it will not be outwardly apparent that an error has occurred. Therefore, be careful!

Error reporting

Errors occurring within a PHP script are reported in accordance with the level of error-reporting specified in the php.ini file. Because the Java code is called from within the PHP script, any errors that arise from the Java code are displayed as PHP errors. If you would like to prevent these errors from being displayed to the browser, simply prefix a @ symbol to the PHP command.