For Programmers: Free Programming Magazines  


Home > Archive > PHP Language > September 2006 > One variable for all the website pages









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author One variable for all the website pages
moi

2006-09-18, 6:57 pm

Hello,

I am designing a website for a freeware and because the version of the
freeware changes often I would like to have one PHP variable containing
the version number. This way I could change the variable in one place and
have all the pages updated in one go.

How can I do that? I do not know where to start :-( (I am a PHP beginner)

Thank you for your help.

--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
PleegWat

2006-09-18, 6:57 pm

Hi,

In article <op.tf2wd9e156icx3@chris-4ac6688f6>, moi says...
> I am designing a website for a freeware and because the version of the
> freeware changes often I would like to have one PHP variable containing
> the version number. This way I could change the variable in one place and
> have all the pages updated in one go.


Create a php file called constants.php or similar. In it, assign your
version number (and possibly other variables you want defined throughout
the site):

<?php
// Constants file

$version = '1.0.0'
?>

Then, in each page where you need this, add an include for this file a
the top:

<?php include('constants.php'); ?>

And where you want to display your version number:

<?php echo $version; ?>

Hope this helps,
--
PleegWat
Remove caps to reply
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com