Re: Perform maths based on a number in a text file [message #183804 is a reply to message #183800] |
Wed, 20 November 2013 12:02 |
David Robley
Messages: 23 Registered: March 2013
Karma:
|
Junior Member |
|
|
drkirkby(at)gmail(dot)com wrote:
> On Monday, 18 November 2013 13:19:50 UTC, The Natural Philosopher wrote:
>
>> I would strongly recommend using a database: setting that up is a bit of
>> a faff, but once set up it provides the sort of 'update by one screen,
>> read buy many others' sort of access that you need. And wont need any
>> file level parsing - you will get your numbers as an array from a Mysql
>> type query.
>>
>> You can even embed the mathematics in the query instead of doing it on
>> PHP, if you want.
>>
>> But all this assumes you are willing to knuckle down and learn basic
>> SQL, mysql administration, and how to set up web forms and the like.
>>
>> If you are as you sound, a relative newcomer, this is a few weeks work
>> :-(
>
> Hi,
> thank you for your thoughs. To be honest, I'm not over keen on using a
> database. I'm not a web designer, but an engineer trying to get data about
> his product on a web page. Maybe the constants will be updated in the
> future, but perhaps they never will. It is certainly not something I
> expect to do on a regular basis. The idea of spending 3 days working on
> this does not attract me.
>
> To answer the question asked by someone else about how the constants will
> get updated. It will be me doing it manually - no program will update
> them. Maybe file_get_contents will do what I want.
>
> Dave
Another possibility would be to add the values as variables in a file and
then include() that file in scripts where the value(s) need to be used.
For example:
variables.inc
<?php
$thisvar = 3;
$thatvar = 7;
?>
And then in any script that needs to know these values something like:
<?php
//.....
include 'variables.inc';
$new_thisvar = $thisvar * 3;
//.....
?>
Add other ingredients to taste :-)
--
Cheers
David Robley
Useless Invention: Self stick frying pan.
|
|
|