PHP-Java-Bridge usage notes, php-java-bridge
This is when I was developing Ping An Bank, using PHP environment locally, Ping An Bank interface is Java interface When using PHP-Java-Bridge, call the interface notes. Because the tutorials on the Internet are basically no longer available, I will post here the latest version (2014-09-19) that I can use. If there is any error, please contact me by email. Thank you.
/**============================================================
* @author ken(695093513@qq.com)
* @date 2014-09-09
*
==============================================================**/
/**================================================== ==========
* Version and Environment
*
========================== ====================================**/
Version:
1. PHP version: up to 5.4, current test is 5.4/5.3
2. JDK: The latest official version, the current test is 1.8
3. php-java-bridge: The official latest version, the current test is 6.2.1
4. Operating system: Windows7 32-bit/64-bit | Linux (Centos6. 5)
/**================================================== ==========
* Installation and use
*
========================== ====================================**/
Step 1: Installation
1. JDK installation: Just install it normally and configure the environment variables
2. PHP installation: Normal Install it
3. Installation of php-java-bridge:
① First download the Java server Tomcat and install it normally. After installation, open the Tomcat server
② Put the downloaded php-java-bridge package into Under webapps
③ Wait for Tomcat to execute the parsing, and a folder with the same name will be generated under the directory
④ Copy the folder to the Apache server for use
(Note: The online tutorial can be used normally, call java system functions and simple jar packages, but you will encounter various problems with complex jar packages, so it is recommended to use this method)
Step 2: Use
1. There is no need to open Tomcat ( It is best to turn it off), open the apache server, double-click to run javabridge.jar, and select port 8080 (javabridge.jar also needs to be placed under the java virtual machine, see the second rule below).
2. Place the jar package under the java virtual machine as much as possible, that is, under the jre installation (for example: C:Program FilesJavajre1.8.0_20libext)
3. There is no need to reference the jar package in the PHP file, because Put it under the virtual machine, and java will automatically call
(Note: the javabridge.jar in point 1 is obtained in step 3 of the first step: installation)
/**================================================== ==========
* Other usage methods and precautions
*
======================== =======================================* */
About the use of various functions of PHP-Java-Bridge:
1. The higher version of java_require is no longer used and cannot be used. Since it is placed under the java virtual machine, there is no need to manually introduce the package file.
2. java_value() is used to obtain the value, and this function must be used to obtain the value
(Special note: If the value needs to be stored in the database, the java_value function must be used, otherwise an error will be reported or the value cannot be stored. Database)
3. java_inspect() performs print_r-like output on instantiations or methods
(Note: Please do not directly use output methods such as var_dump to output java classes, methods, and variables. You need to use java_inspect or java_value. For example: var_dump(java_inspect($abc)))
4. For instantiation, use $test = new Java("Test"). If there are parameters in the instantiation method, you can use new Java("Test", "pram")
Notes:
1. Be sure to reference java.inc and make sure the reference is correct
2. Be sure to place the jar package where it can be referenced, such as under the java virtual machine jre
3. Call Java in PHP using the writing method of PHP
/**================================================== ==========
* Appendix 1: Handling various error reports
* Appendix 2: PHP example code
* Appendix 3: Directory map after decompressing the PHP-Java-bridge file package
*
============================================== ===================**/
Appendix 1: Handling various error reporting issues
1. Refer to the "Other uses" above "Methods and Precautions", most of the problems are path reference problems. As long as they are handled properly and obtained correctly, there will be no problems
Appendix 2: PHP example code
require_once("/java/Java.inc"); $util = new Java("com.sdb.payclient.core.PayclientInterfaceUtil"); $input = new Java("com.ecc.emp.data.KeyedCollection"); $signDataput = new Java("com.ecc.emp.data.KeyedCollection"); $input->put("masterId","111111"); $input->put("orderId","222222"); $signDataput = $util->getSignData($input); $orig = java_values($signDataput->getDataValue("orig")); $sign = $signDataput->getDataValue("sign"); echo java_values($sign);
Appendix 3: Directory map after decompression of the PHP-Java-bridge file package
bridge --java java.inc JavaProxy.php --WEB-INF --cgi --... --lib php-script.jar php-servlet.jar --pear web.xml weblogic.xml

PHP is used to build dynamic websites, and its core functions include: 1. Generate dynamic content and generate web pages in real time by connecting with the database; 2. Process user interaction and form submissions, verify inputs and respond to operations; 3. Manage sessions and user authentication to provide a personalized experience; 4. Optimize performance and follow best practices to improve website efficiency and security.

PHP uses MySQLi and PDO extensions to interact in database operations and server-side logic processing, and processes server-side logic through functions such as session management. 1) Use MySQLi or PDO to connect to the database and execute SQL queries. 2) Handle HTTP requests and user status through session management and other functions. 3) Use transactions to ensure the atomicity of database operations. 4) Prevent SQL injection, use exception handling and closing connections for debugging. 5) Optimize performance through indexing and cache, write highly readable code and perform error handling.

Using preprocessing statements and PDO in PHP can effectively prevent SQL injection attacks. 1) Use PDO to connect to the database and set the error mode. 2) Create preprocessing statements through the prepare method and pass data using placeholders and execute methods. 3) Process query results and ensure the security and performance of the code.

PHP and Python have their own advantages and disadvantages, and the choice depends on project needs and personal preferences. 1.PHP is suitable for rapid development and maintenance of large-scale web applications. 2. Python dominates the field of data science and machine learning.

PHP is widely used in e-commerce, content management systems and API development. 1) E-commerce: used for shopping cart function and payment processing. 2) Content management system: used for dynamic content generation and user management. 3) API development: used for RESTful API development and API security. Through performance optimization and best practices, the efficiency and maintainability of PHP applications are improved.

PHP makes it easy to create interactive web content. 1) Dynamically generate content by embedding HTML and display it in real time based on user input or database data. 2) Process form submission and generate dynamic output to ensure that htmlspecialchars is used to prevent XSS. 3) Use MySQL to create a user registration system, and use password_hash and preprocessing statements to enhance security. Mastering these techniques will improve the efficiency of web development.

PHP and Python each have their own advantages, and choose according to project requirements. 1.PHP is suitable for web development, especially for rapid development and maintenance of websites. 2. Python is suitable for data science, machine learning and artificial intelligence, with concise syntax and suitable for beginners.

PHP is still dynamic and still occupies an important position in the field of modern programming. 1) PHP's simplicity and powerful community support make it widely used in web development; 2) Its flexibility and stability make it outstanding in handling web forms, database operations and file processing; 3) PHP is constantly evolving and optimizing, suitable for beginners and experienced developers.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

SublimeText3 Chinese version
Chinese version, very easy to use

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

WebStorm Mac version
Useful JavaScript development tools

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment