-
Notifications
You must be signed in to change notification settings - Fork 36
Char
memory-agape edited this page Apr 18, 2019
·
4 revisions
_Char class is provided APIs for emulating Java's char on PHPJava.
This class not been determined of features.
The class can be pass char type into Java if you want.
For an example as follows:
- Write Java:
class Test
{
public static void echo(byte[] text)
{
System.out.println(new String(text));
}
}- Compile Java:
$ javac -UTF8 /path/to/Test.java
- Call the
echomethod as follows:
<?php
use PHPJava\Core\JavaClass;
use PHPJava\Core\Stream\Reader\FileReader;
use PHPJava\Kernel\Types\\_Byte;
(new JavaClass(new FileReader('/path/to/Test.class')))
->getInvoker()
->getStatic()
->getMethods()
->call(
'echo',
array_map(
function ($char) {
return new _Char(ord($char));
},
preg_split(
'//',
"HelloWorld!",
-1,
PREG_SPLIT_NO_EMPTY
)
)
);- Get the result
$ php /path/to/Test.php
HelloWorld!
public function __construct($value)Initiate a boolean type for Java.
| Name | Type | Description |
|---|---|---|
| $value | mixed | Specify byte value |
public function getValue()Return real value.
No parameter.
public function getTypeNameInJava()Return type name in Java.
No parameter.
public function getTypeNameInPHP()Return type name in PHP.
No parameter.
public function __toString()Return stringified real value.
No parameter.
- The Contribution Guide
- CHANGELOG
- How to run JavaClass
- How to run JavaArchive
- How to run Kotlin
-
Provided classes
- Core
- Types
- Utilities
- Provided options
- Operation Injector