www.webdeveloper.com
Results 1 to 5 of 5

Thread: Use of Constants in HTML

  1. #1
    Join Date
    Jun 2005
    Location
    London, UK
    Posts
    191

    Question Use of Constants in HTML

    How do I use constants in the HTML itself? I mean I have found plenty of usage of constants within PHP scripts themselves but can I use them to build a link, for example (directly in <a href="">)?

    Would I need to do use php tags within the href to do so? I have seen in phpBB for example, that constants get used in the HTML templates like:

    <a href="DIR_ROOT">Home</a>

    But it didn't seem to work when I did it.

    Any tips or good links?

  2. #2
    Join Date
    Feb 2005
    Posts
    345
    first define a variable and then insert it like this:
    Code:
    <a href="<?php echo $variable;?>">Home</a>
    make sure the html file has a .php ending
    free music: comatronic

  3. #3
    Join Date
    Jan 2005
    Location
    Alicante (Spain)
    Posts
    7,739

  4. #4
    Join Date
    Jun 2005
    Location
    London, UK
    Posts
    191
    Quote Originally Posted by bokeh
    You can't access contants from within a quoted string literal. Use concatenation.
    In what way? Example please?

    I mean I want to define constants for the root, the stylesheet, includes, etc.

    If I create all constants in a separate file, does that script need to be run to define the constants? If so, how do I include that file, considering my constant for the root directory for example won't have been defined yet?
    Last edited by Mig; 05-16-2007 at 02:22 PM.

  5. #5
    Join Date
    Mar 2005
    Location
    Sydney, Australia
    Posts
    7,974
    <a href="<?php echo DIR_ROOT ?>">Home</a>
    Stephen

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles