Example 1: it is very easy to create and use your own JAVA class. Create a new phptest. java file and place it in your java. class. path Directory. the file content is as follows: publicclassphptest {/*** AsampleofaclassthatcanworkwithPHP * NB
Example 1: Create and use your own JAVA class
It is very easy to create your own JAVA class. Create a new phptest. java file and place it in your java. class. path Directory. the file content is as follows:
Public class phptest {
/**
* A sample of a class that can work with PHP
* NB: The whole class must be public to work,
* And of course the methods you wish to call
* Directly.
*
* Also note that from PHP the main method
* Will not be called
*/
Public String foo;
/**
* Takes a string and returns the result
* Or a msg saying your string was empty
*/
Public String test (String str ){
If (str. equals ("")){
Str = "Your string was empty .";
}
Return str;
}
/**
* Whatisfoo () simply returns the value of the variable foo.
*/
Public String whatisfoo (){
Return "foo is" + foo;
}
/**
* This is called if phptest is run from the command line
* Something like
* Java phptest
* Or