Forum Moderators: coopster
<?php
$dothemath = include('ronviews.php') / include('ronvids.php');echo 'The answer is $dothemath';
?>
Something like that?
Btw, I do get an error from that, which is why I ask. =)
Thanks!
Spanger
<?php
$ronviews = include'ronviews.php';
$ronvids = include'ronvids.php';
$dothemath = $ronviews / $ronvids;
echo 'The answer is $dothemath';
?>
Doesn't work though. I get this:
3,330,03044The answer is $dothemath
=/
What am I doing wrong? (it's probably something really simple. =¦)
Thanks!
Spanger
maybe this explains it
[php.net...]
Handling Returns: It is possible to execute a return() statement inside an included file in order to terminate processing in that file and return to the script which called it. Also, it's possible to return values from included files. You can take the value of the include call as you would a normal function. This is not, however, possible when including remote files unless the output of the remote file has valid PHP start and end tags (as with any local file). You can declare the needed variables within those tags and they will be introduced at whichever point the file was included.
echo 'The answer is '.$dothemath;
or
echo "The answer is $dothemath"; #use double quotes
// get contents of a file into a string
$filename = "/usr/local/something.txt";
$handle = fopen($filename, "r");
$contents = fread($handle, filesize($filename));
fclose($handle);
In order to actually do math on your vars, though, you'll have to do some type switching to make sure you operating on numbers, not strings.
I'm not sure how you "ended up" with php files of just numbers, though. Probably a better way to do this from the start...