PluginProbe
Visualizer – Tables & Charts Manager with Built-in AI Generator / 2.2.0
Visualizer – Tables & Charts Manager with Built-in AI Generator v2.2.0
4.0.8 4.0.7 4.0.6 4.0.5 4.0.4 4.0.3 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.1 3.1.2 3.1.3 3.10.0 3.10.1 3.10.10 3.10.11 3.10.12 3.10.13 3.10.14 3.10.15 3.10.2 3.10.3 All 149 releases
visualizer / vendor / phpoffice / phpexcel / Examples / Quadratic.php

Quadratic.php in Visualizer – Tables & Charts Manager with Built-in AI Generator 2.2.0, at vendor/phpoffice/phpexcel/Examples/Quadratic.php

69 lines 2.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <html>
2 <head>
3 <title>Quadratic Equation Solver</title>
4 </head>
5 <body>
6 <?php
7
8 /** Error reporting **/
9 error_reporting(E_ALL);
10
11 /** Include path **/
12 set_include_path(get_include_path() . PATH_SEPARATOR . dirname(__FILE__) . '/../Classes/');
13
14 ?>
15 <h1>Quadratic Equation Solver</h1>
16 <form action="Quadratic.php" method="POST">
17 Enter the coefficients for the Ax<sup>2</sup> + Bx + C = 0
18 <table border="0" cellpadding="0" cellspacing="0">
19 <tr><td><b>A&nbsp;</b></td>
20 <td><input name="A" type="text" size="8" value="<?php echo (isset($_POST['A'])) ? htmlentities($_POST['A']) : ''; ?>"></td>
21 </tr>
22 <tr><td><b>B&nbsp;</b></td>
23 <td><input name="B" type="text" size="8" value="<?php echo (isset($_POST['B'])) ? htmlentities($_POST['B']) : ''; ?>"></td>
24 </tr>
25 <tr><td><b>C&nbsp;</b></td>
26 <td><input name="C" type="text" size="8" value="<?php echo (isset($_POST['C'])) ? htmlentities($_POST['C']) : ''; ?>"></td>
27 </tr>
28 </table>
29 <input name="submit" type="submit" value="calculate"><br />
30 If A=0, the equation is not quadratic.
31 </form>
32
33 <?php
34 /** If the user has submitted the form, then we need to execute a calculation **/
35 if (isset($_POST['submit'])) {
36 if ($_POST['A'] == 0) {
37 echo 'The equation is not quadratic';
38 } else {
39 /** So we include PHPExcel to perform the calculations **/
40 include 'PHPExcel/IOFactory.php';
41
42 /** Load the quadratic equation solver worksheet into memory **/
43 $objPHPExcel = PHPExcel_IOFactory::load('./Quadratic.xlsx');
44
45 /** Set our A, B and C values **/
46 $objPHPExcel->getActiveSheet()->setCellValue('A1', $_POST['A']);
47 $objPHPExcel->getActiveSheet()->setCellValue('B1', $_POST['B']);
48 $objPHPExcel->getActiveSheet()->setCellValue('C1', $_POST['C']);
49
50
51 /** Calculate and Display the results **/
52 echo '<hr /><b>Roots:</b><br />';
53
54 $callStartTime = microtime(true);
55 echo $objPHPExcel->getActiveSheet()->getCell('B5')->getCalculatedValue().'<br />';
56 echo $objPHPExcel->getActiveSheet()->getCell('B6')->getCalculatedValue().'<br />';
57 $callEndTime = microtime(true);
58 $callTime = $callEndTime - $callStartTime;
59
60 echo '<hr />Call time for Quadratic Equation Solution was '.sprintf('%.4f',$callTime).' seconds<br /><hr />';
61 echo ' Peak memory usage: '.(memory_get_peak_usage(true) / 1024 / 1024).' MB<br />';
62 }
63 }
64
65 ?>
66
67 </body>
68 <html>
69