PHP Function (Link_Maker)

Status
Not open for further replies.

litewarez

Active Member
1,367
2008
1
0
hey this is just a simple bit of code that i just made for another project and thought it might be usfull to ppl so here it is....

Code:
function make_link($url,$name,$class){
    $link = '<a href="'.$url.'"';
    if($class){
        $link .= ' class="'.$class.'"';
    }
    $link .= $name ? '>'.$name.'</a>' : '>'.$url.'</a>';
    echo $link;
}

there are 4 modes to create links...

1.
Code:
make_link('http://www.litewarez.com','','');
(>> <a href="http://www.litewarez.com">http://www.litewarez.com</a>

2.
Code:
make_link('http://www.litewarez.com','LiteWarez Home','');
(>> <a href="http://www.litewarez.com">Litewarez Home</a>

3.
Code:
make_link('http://www.litewarez.com','LiteWarez Home','this_is_css_class');
(>> <a href="http://www.litewarez.com" class="this_is_css_class">Litewarez Home</a>

4.
Code:
make_link('http://www.litewarez.com','','this_is_css_class');
(>> <a href="http://www.litewarez.com" class="this_is_css_class">http://www.litewarez.com</a>

as you can see this small snippep has good functionality and as long as you have an url you can create a link..

also its greate for your templates if you use this throughout your scripts..

peace.
 
Status
Not open for further replies.
Back
Top