> From: "Stephen" <[EMAIL PROTECTED]>
> Sent: Wednesday, November 20, 2002 8:52 PM
> Subject: Re: [PHP] Reading part of a file

> What I'm doing is having a PHP part, let's say that it's a calculator that
> adds module, that does the adding. The second part of the file is the form
> that the user uses to put in the numbers. That's what I want to do...

If you have a piece of php code sitting in a file, you can use it anytime by
including or requiring it.  Say you have a file named add.php and in it you
--- Top of file ---
function add($addend1, $addend2) {
   return ($addend1 + $addend2);
--- End of file ---

in another file named page calc.php you can do a:
--- Top of file ---
require 'add.php';
   $sum = add($_POST['addend1'],$_POST['addend2']);
   echo "<br>The sum of {$_POST['addend1']} and {$_POST['addend2']} is
<form method="post" action="calc.php">
<input type="text" name="addend1" size="10"><br>
<input type="text" name="addend2" size="10"><br>
<input type="submit" name="submit" value="Add them">
--- End of file ---

PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to