Login   Register  
PHP Classes
elePHPant
Icontem

File: sample.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Reza Salehi  >  complex  >  sample.php  >  Download  
File: sample.php
Role: Example script
Content type: text/plain
Description: sample.php
Class: complex
Performs operations on complex numbers
Author: By
Last change:
Date: 11 years ago
Size: 727 bytes
 

Contents

Class file image Download
<?php
    
include('complex.class.php');
    
//----
    // this class gets 2 complex numbers and calculates add, sub, mul & div of them.
    // useful for educational use.
    //----
    
    //---- 2 complex number.
    
$n1['re']=2;
    
$n1['im']=-10;
    
$n2['re']=-1;
    
$n2['im']=0;
    
    
$c=new complex($n1$n2);
    
    
$sum=$c->add();
    
$sub=$c->sub();
    
$mul=$c->mul();
    
$div=$c->div();
    
    print (
'num1 = '.$n1['re'].' '.$n1['im'].'i'.'<br>');
    print (
'num2 = '.$n2['re'].' '.$n2['im'].'i'.'<br><br>');
    
    print (
'add = '.$sum['re'].' '.$sum['im'].'i'.'<br>');
    print (
'sub = '.$sub['re'].' '.$sub['im'].'i'.'<br>');
    print (
'mul = '.$mul['re'].' '.$mul['im'].'i'.'<br>');
    print (
'div = '.$div['re'].' '.$div['im'].'i'.'<br>');
    
?>