Re: Storing formulas

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Mike Smith wrote:
...
> 
> TopMeasurment+1.6875+OutOfPlumbWall
> 
...
> static). Other formulas have 10 and 12 "variables" in them. How have
> others gone about storing formulas that require such modifications?
> 
> TIA,
> Mike Smith

If I was programming this I would probably create 16 functions for
whatever the formula is supposed to produce.  If you believe that a
constant will usually work you can have that as a default.

<?php

define('TABLE_STANDARD_ERROR', 1.6875);

function table_get_length($top, $plumb, $se = null) {
  if (null === $se) {
    $se = TABLE_STANDARD_ERROR;
  }
  return $top + $se + $plumb;
}

/** Now the fun begins... assume that $_POST is populated with data and
it has been scrubbed for improper input... */
$length = table_get_length($_POST['top'], $_POST['plumb'], $_POST['se']);

echo "In order to make the table, you need $length inches of wood.\n"

?>

-- 
Teach a man to fish...

NEW? | http://www.catb.org/~esr/faqs/smart-questions.html
STFA | http://marc.theaimsgroup.com/?l=php-general&w=2
STFM | http://www.php.net/manual/en/index.php
STFW | http://www.google.com/search?q=php
LAZY |
http://mycroft.mozdev.org/download.html?name=PHP&submitform=Find+search+plugins

Attachment: signature.asc
Description: OpenPGP digital signature


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux