Heim  >  Artikel  >  php教程  >  PHP 5, PHP/Java Bridge & Apache on XP PRO + SP2 and

PHP 5, PHP/Java Bridge & Apache on XP PRO + SP2 and

WBOY
WBOYOriginal
2016-06-06 19:46:561091Durchsuche

Example - SalesTax.java, salestax.php, salestax.htm C:\Program Files\Apache Group\Apache2\htdocs\test\SalesTax.java. import java.util.*;import java.text.*;public class SalesTax{ private double tax = 0.0; private double price = 0.0; private

Example - SalesTax.java, salestax.php, salestax.htm

C:\Program Files\Apache Group\Apache2\htdocs\test\SalesTax.java.

import java.util.*;
import java.text.*;

public class SalesTax
{

    private double tax = 0.0;
    private double price = 0.0;
    private double salesTax = 0.0;

    public SalesTax()
    {}

    public String SalesTax(double price, double salesTax)
    {
        tax = price * salesTax;

        NumberFormat nf = null;

        nf = NumberFormat.getCurrencyInstance();

        String priceOut = nf.format(price);
        String taxOut = nf.format(tax);

        nf = NumberFormat.getPercentInstance();
        String salesTaxOut = nf.format(salesTax);

        String str = "Sales Tax of " + salesTaxOut +
            " on " + priceOut + " equals " + taxOut + ".";

        return str;
    }
}

C:\Program Files\Apache Group\Apache2\htdocs\test\salestax.php

<?php if (isset($_POST["submit"]))
{
	java_require('http://localhost/test/SalesTax.jar');

	$salesTax = new Java("SalesTax");

	$price = (double) $_POST["price"];
	$tax = (double) $_POST["tax"];

	echo (String) $salesTax->SalesTax($price, $tax);
}

?>

C:\Program Files\Apache Group\Apache2\htdocs\test\salestax.htm.


<title></title>



Price: ($)

Tax Rate: (0.1 for 10%)

PHP 5, PHP/Java Bridge & Apache on XP PRO + SP2 and

PHP 5, PHP/Java Bridge & Apache on XP PRO + SP2 and

Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn
Vorheriger Artikel:php给图片加文字Nächster Artikel:php计算两数组交集两个函数