Cómo imitar el comportamiento de enlace automático de desbordamiento de pila

Con PHP, ¿cómo puedo imitar el comportamiento de enlace automático del Desbordamiento de pila (que por cierto es increíblemente genial)?

Por ejemplo, la siguiente URL:

http://www.stackoverflow.com/questions/1925455/how-to-mimic-stackoverflow-auto-link-behavior

Se convierte en esto:

<a title="how to mimic stackoverflow auto link behavior" rel="nofollow" href="http://www.stackoverflow.com/questions/1925455/how-to-mimic-stackoverflow-auto-link-behavior">stackoverflow.com/questions/1925455/…</a>

Realmente no me importa eltitle&nbsp;Atributo en este caso.

Y esto:

http://pt.php.net/manual/en/function.base-convert.php#52450

Se convierte en esto:

<a rel="nofollow" href="http://pt.php.net/manual/en/function.base-convert.php#52450">pt.php.net/manual/en/…</a>

¿Cómo puedo hacer una función similar en PHP?

PD: Revisa mis comentarios sobre esta pregunta para ver algunos ejemplos y comportamientos más.