1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

I want to make a small config file

Discussion in 'Programming' started by Drew007, Aug 15, 2007.

  1. #1
    I want the following info to appear throughout the site, where I put some code:

    SiteName: Bob's Computer Shop
    SiteOwner: BoB Smith
    URL: www.example.com

    Sample paragraph:

    -------------

    <SiteName> is owned by <SiteOwner>. We are here to help <SiteURL> customers.

    --------------

    Thank you in advance,

    Drew
     
    Drew007, Aug 15, 2007 IP
  2. itssangy

    itssangy Peon

    Messages:
    135
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #2
    What server side language are you using?
     
    itssangy, Aug 16, 2007 IP
  3. Drew007

    Drew007 Peon

    Messages:
    310
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thanks for your reply. I am using PHP.
     
    Drew007, Aug 16, 2007 IP
  4. sea otter

    sea otter Peon

    Messages:
    250
    Likes Received:
    23
    Best Answers:
    0
    Trophy Points:
    0
    #4
    I'm assuming from the thread title that you want to read the information from a config file.

    First, create the config file as shown here. For this example, save the file with the name siteinfo.php

    
    <?php exit;?>
    SiteName = "Bob's Computer Shop"
    SiteOwner = "Bob Smith"
    SiteURL = "http://www.example.com"
    
    PHP:
    Now load the config file data:

    
       $info = parse_ini_file('siteinfo.php');
    
    PHP:
    Lastly, display the data in your html code:

    
    <?=$info['SiteName']?> is owned by <?=$info['SiteOwner']?>. We are here to help <?=$info['SiteURL']?> customers.
    
    PHP:
    Depending on how you're generating the page, it might be easier to simply output the entire above line in php:

    
    <?php
    echo $info['SiteName'], ' is owned by ', $info['SiteOwner'], '. We are here to help ', $info['SiteURL'], ' customers.';
    ?>
    
    PHP:
     
    sea otter, Aug 16, 2007 IP
    Drew007 likes this.
  5. Drew007

    Drew007 Peon

    Messages:
    310
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Great thanks! Rep added.
     
    Drew007, Aug 27, 2007 IP