Include Function
Moderator: General Moderators
Include Function
I was wondering how to do this:
Have a list of values for use in a page
Be able to add another set of values using a page
Make sure that the values can be used in different pages
Have a value to display how many sets of values there are
Have a list of values for use in a page
Be able to add another set of values using a page
Make sure that the values can be used in different pages
Have a value to display how many sets of values there are
a bit vague... You mean something like a config file?
...that something like you want?
Code: Select all
//config.php
$config['name'] = "me";
$config['place'] = "here";
$config['age'] = 123;
#etc
//moreconfig.php
require 'config.php';
$config['occupation'] = "astronaut";
$config['something'] = 'e';
#etc
//anotherfile.php
require 'config.php';
# OR
require 'moreconfig.php';- Ambush Commander
- DevNet Master
- Posts: 3698
- Joined: Mon Oct 25, 2004 9:29 pm
- Location: New Jersey, US
Ah, yeah. For something like that'd just use MySQL or something.
http://php.net/mysqlSo how do I use the variables?
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
Code: Select all
$result = "SELECT * FROM `config`";
$result = mysql_query($result) or die(mysql_error());
$config = mysql_fetch_assoc($result);
$max_pages = $config['max_pages'];but another way to approach this is have an ini with set variables and access those variables through parse_ini() and edit the form file through fopen, fwrite, fread, and fclose or file_get_contents() and file_put_contents() if you have php5 installed.
I would recommend using a database though.