simple php echo function :)

ok so its obvious im a bit dumb when it comes to coding :slight_smile: but can anyone set me straight. I have a problem that I need to update “amounts” from time to time and its annoying going through every page to find the amount to update it to the new amount. So I figured I would use the php function to solve my headache. This is what I have below:

The php below would be called amount.php etc
[php]

<?php $amountone = "\£500"; $amounttwo = "\£400"; $amountthree = "\£300"; ?>

[/php]


But because i would need to make several calls on the same page for various bonuses… Would I use the
[php]<?php include "amount.php";echo "$amountone"; ?>[/php] for each bonus ?

Or is there a way of calling the “amount.php” once into the page and then just using:

Amount one is: [php]<?php echo "$amountone"; ?>[/php]
Amount two is: [php]<?php echo "$amounttwo"; ?>[/php]

etc

try this
[php]require_once (“amount.php”);
echo $amountone;
echo $amounttwo;
echo $amountthree;[/php]

Hi Andrew,

Trouble is I do not need the amounts all together, they would be scattered all over the page. Can I use the require once call and then use seperate echo’s ?

like:

[php]<?php require_once ("amount.php"); ?>[/php]
This is some content: This is some content.
This is some content: This is some content.

blah blah amount is: [php]<?php echo "$amountone"; ?>[/php]…
This is some content: This is some content.
This is some content: This is some content
did you know blah blah amount is: [php]<?php echo "$amountone"; ?>[/php]

Yes you can and you do not need the “” around a variable in an echo statement.

Much appreciated Andrew, many thanks. I shall have a bash and see how it goes.

Sponsor our Newsletter | Privacy Policy | Terms of Service