How to pass variables into link path within l() function?
Some Examples

Example 1: Link to front page

&lt;?php
// example 1:  front page
print l(t('Home'), '&lt;front&gt;'); 
?&gt;


Example 2: Link to front page and open in new window

&lt;?php
print l(t('Home'), '&lt;front&gt;',array('attributes'=&gt;array('target'=&gt;'blank'))); 
?&gt;


Example 3: How to use html

&lt;?php
print l('&lt;span class="front"&gt;Home&lt;/span&gt;', '&lt;front&gt;',array('html' =&gt; TRUE)); 
?&gt;


Example 4: How to use image instead of text link

Lets create my picture path

&lt;?php 
global $base_url;
$path = "$base_url/sites/default/files/ceo5.png";
print l('&lt;img src="'.$path.'" alt="Webemania CEO Image" /&gt;', 'sites/default/files/ceo5.png', array('html' =&gt; TRUE));
?&gt;


Example 5: Add class, ids, etc

&lt;?php
// add a new class to my php ini configuration path
print l(  t('PHP ini configuration'),  'node/3',  array('attributes' =&gt;array('class'=&gt;'php-ini-conf', 'id'=&gt;'phpini-conf') ));
?&gt;


Example 6: Adding query string to links

Adding a query string to example 5

&lt;?php
// adding query string on example:5
print l(  t('PHP ini configuration'),  'node/33',  array('attributes' =&gt;array('class'=&gt;'php-ini-conf', 'id'=&gt;'phpini-conf'), 'query'=&gt;array('id'=&gt;'5','status'=&gt;'ok') ));
?&gt;


The output will be: 

http://webemania.com/blog/php-ini-configuration?id=5&amp;status=ok

Example 7: Adding destination to query link

&lt;?php
print l(  t('edit'),  'node/'.$nid.'/edit',  array('query' =&gt; drupal_get_destination() ));
?&gt;


Example 8: Create a hash-only link (to #)

&lt;?php
print l('linktext', '', array('fragment' =&gt; ' ', 'external' =&gt; TRUE));
?&gt;


Example 9: Specific portions of a page

Use fragment attributes Go to php ini configurations short open tag portion: PHP Short open tag

&lt;?php
l(  t('PHP ini configuration'),  'node/33',  array('attributes' =&gt;array('class'=&gt;'php-ini-conf', 'fragment' =&gt; "php-tag")));
?&gt;


References:

How and why to use l() function to create links in Drupal