PHP Classes

File: sample.php

Recommend this page to a friend!
  Classes of Reza Salehi   root_finder   sample.php   Download  
File: sample.php
Role: Example script
Content type: text/plain
Description: example
Class: root_finder
Calculates the roots of a given f(x) function
Author: By
Last change: redirect to the generated image.
Date: 6 years ago
Size: 1,173 bytes
 

Contents

Class file image Download
<?php
///////////////////////////////////////////////////////////////////
//---- Reza Salehi
//---- zaalion@yahoo.com
//---- free for non-commercial use.
///////////////////////////////////////////////////////////////////

    //---- including class file.
   
include("root_finder.class.php");
   
//---- making new instance of object.
   
$r=new root_finder($_POST["function_x"],$_POST["x_start"],$_POST["x_end"],$_POST["tolerance"],$_POST["step"]);
   
//---- call draw method of root_finder onject to get the result and digram.
   
$r->draw();
header("Location: root.jpg");

///////////////////////////////////////////////////////////////////////
//---- if you are not interested in diagram and want to get an array of your f(x) roots,
//---- you can call class "find()" method of object. then by getting "roots" property you
//---- have the roots .
//---- example :
//---- 1: $r=new root_finder($_POST["function_x"],$_POST["x_start"],$_POST["x_end"],$_POST["tolerance"],$_POST["step"]);
//---- 2: $r->find();
//---- 3: for($i=0;$i<count($r->roots);$i++) print($r->roots[$i]." ");
///////////////////////////////////////////////////////////////////////

?>