SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Zealot sparkele's Avatar
    Join Date
    Jan 2001
    Location
    Nellyville
    Posts
    128
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question PHP Idea: Useful or Not?

    When using some webservers that you aren't 100% sure that you will be using in the future, how about inserting a print code for each link, directory, and image and including addresses in a .inc file.
    Example:
    PHP Code:
    <?php 
    ###############
    #addresses.inc#
    ###############
    $logo "http://www.yosite.com/images/logo.gif";
    ?>
    And if you change domains or directories..

    PHP Code:
    <?php
    ######################
    #a few weeks later...#
    ######################
    $logo ="http://www.mysite.com/new/site4/img/logo.gif";
    ?>

    Then you would put that into an HTML file like so:

    PHP Code:
    <IMG SRC="<?php print($logo); ?>
    This would prevent long and tedious re-coding, and since my sites arent all dynamic yet, this seems like a good idea. Give me your opinion.

  2. #2
    SitePoint Wizard silver trophy someonewhois's Avatar
    Join Date
    Jan 2002
    Location
    Canada
    Posts
    6,364
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Better:

    PHP Code:
    <?php
    $IMAGE_PATH 
    "http://mydomain.com/images/";
    $URL_PATH "http://mydomain.com/";
    Then call it:

    PHP Code:
    <IMG SRC="<?=$IMAGE_PATH?>logo.gif">

  3. #3
    Ceci n'est pas Zoef Zoef's Avatar
    Join Date
    Nov 2002
    Location
    Malta
    Posts
    1,111
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    eh... why not just use relative url's?
    English tea - Italian coffee - Maltese wine - Belgian beer - French Cognac

  4. #4
    Made with a Mac! philm's Avatar
    Join Date
    Sep 2001
    Location
    Portsmouth, UK
    Posts
    735
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Because that would be too easy for the coding geeks

    What would they have to fiddle with then?

  5. #5
    SitePoint Zealot
    Join Date
    Mar 2001
    Location
    North Wales, UK
    Posts
    181
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yup:

    Code:
    <img src="/images/logo.gif">
    Easy .

  6. #6
    Prolific Blogger silver trophy Technosailor's Avatar
    Join Date
    Jun 2001
    Location
    Before These Crowded Streets
    Posts
    9,446
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    easy but not always the best way. config.php files with all the variables are some of the best ideas around. Also, if you're creating a dstributable app, this is useful. Most bulletin board software uses a similar technique.

    Aaron
    Aaron Brazell
    Technosailor



  7. #7
    SitePoint Zealot sparkele's Avatar
    Join Date
    Jan 2001
    Location
    Nellyville
    Posts
    128
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The only problem was that my whole point was to make it easy to change an image's or other document's location if I ever had to move, changed web addresses, or changed file directory structure. In response to someonewhois, I would have to change every single page if I changed even one file or directory. That would totally elminate the purpose.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •