How to create an EMPTY anchor-only link with l()? I'm trying to use l() to get something like &lt;a href='#' ...&gt;, for ajax-calling purposes.  https://stackoverflow.com/questions/1698453/drupal-creating-anchor-only-link-with-l is very close to the right thing -- use an option in l() like 'fragment' =&gt; 'foo' to produce a link like &lt;a href='#foo'...&gt; -- but I'm trying to get a clean '#'.  Is there any way to do this, or should I just put something in as part of the fragment and not worry about it?
PHP typecasting pop quiz time! (Full disclosure: I didn't win in our office). 

As pointed out already, this is the code in l() that we're concerned with:

if (isset($options['fragment']) &amp;&amp; $options['fragment'] !== '') {
  $options['fragment'] = '#' . $options['fragment'];
}


So here's the question: What value casts to an empty string but passes the following?

(isset($var) &amp;&amp; $var !== '')


The answer is: FALSE!

So, we could try this:

l(t('My link'), NULL, array('fragment' =&gt; FALSE));


Which gives us:

&lt;a href="/#"&gt;My link&lt;/a&gt;


Thankfully we can strip that leading slash by passing along external =&gt; TRUE:

l(t('My link'), NULL, array('external' =&gt; TRUE, 'fragment' =&gt; FALSE));


Which gives us:

&lt;a href="#"&gt;My link&lt;/a&gt;


Boom. The things we do to avoid concatenating html strings manually, eh?

Postscript:

I'm not sure I'd actually recommend printing a link like this from php under normal circumstances. Without your javascript, all that link is going to do it jump your user to the top of the page (which, to my slight surprise, is specced behaviour). It should probably point somewhere that works without javascript. 

If the link really only makes sense with javascript around (like the controls for a js-only slideshow or something), I think it's better to add the link to the page with javascript. Alternatively, if you really want to put it in your source, make sure it's display:none'd by default. Drupal has the .js class on the html for then showing it when javascript is around.