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:
But it didn't seem to work when I did it.
Any tips or good links?
first define a variable and then insert it like this:
make sure the html file has a .php ending
<a href="<?php echo $variable;?>">Home</a>
You can't access contants from within a quoted string literal. Use concatenation.
In what way? Example please?
Originally Posted by bokeh
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.
<a href="<?php echo DIR_ROOT ?>">Home</a>
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)