Latest

Archive

Community news

C++

Communities and Content

Databases

Editorials

Emacs

General

HTML

Java

Notices

PHP

XML

Apache

C++

Database

General

HTML

Java

Javascript

Linux

Object oriented programming

Open source

Perl

PHP

Python

Ruby

SOAP

XML

Suggest a link

Advertise on zez

Contribute

Contact us

About zez


Interfacing with Java from PHP



Java and PHP


In this small tutorial I will show you how to make a simple calculator using a java class to calculate the results and PHP to present the results and interface with the user. The example code can be tested here.

We will first start with the calculator class. I've called the class eZCalc. The code is shown below:


public class eZCalc
{
    float NumberA, NumberB;
    
    public eZCalc( )
    {
        NumberA = 1;
        NumberB = 1;
    }

    public void setA( float a )
    {
        NumberA = a;    
    }
    
    public void setB( float b )
    {
        NumberB = b;
    }

    public float multiply()
    {
        return NumberA * NumberB;
    }

    public float divide()
    {
        return NumberA / NumberB;
    }

    public float add()
    {
        return NumberA + NumberB;
    }

    public float subtract()
    {
        return NumberA - NumberB;
    }
}



<< Previous page | 1 | < 2 > | 3 | 4 | 5 | Next page >> | Printer-friendly page |

Comment List


There are no comments.


Forgot your password?

Register a new user

Results

Polls