<p>Wordpress provides a function called "the_permalink()" that returns, you guessed it!, the permalink to a given post while in a loop of posts.</p>

<p>I am trying to URL encode that permalink and when I execute this code:</p>

<pre><code>&lt;?php
print(the_permalink());
$permalink = the_permalink();
print($permalink);
print(urlencode(the_permalink()));
print(urlencode($permalink));
$url = 'http://wpmu.local/graphjam/2008/11/06/test4/';
print($url);
print(urlencode($url));
?&gt;
</code></pre>

<p>it produces these results in HTML:</p>

<pre><code>http://wpmu.local/graphjam/2008/11/06/test4/
http://wpmu.local/graphjam/2008/11/06/test4/
http://wpmu.local/graphjam/2008/11/06/test4/
http://wpmu.local/graphjam/2008/11/06/test4/
http%3A%2F%2Fwpmu.local%2Fgraphjam%2F2008%2F11%2F06%2Ftest4%2F
</code></pre>

<p>I would expect lines 2, 3 and 5 of the output to be URL encoded, but only line 5 is so.  Thoughts?</p>

According to the docs,
```
the_permalink
```
prints the permalink vs returns it. So,
```
urlencode
```
isn't getting anything to encode.
Try
```
get_permalink
```
.
[
EDIT
]
A little late for an edit, but I didn't realize the print counts were such an issue.
Here's where they're all coming from:
```
```
<?php
print(the_permalink());                                // prints (1)
$permalink = the_permalink();                          // prints (2)
print($permalink);                                     // nothing
print(urlencode(the_permalink()));                     // prints (3)
print(urlencode($permalink));                          // nothing
$url = 'http://wpmu.local/graphjam/2008/11/06/test4/'; 
print($url);                                           // prints (4)
print(urlencode($url));                                // prints (5)
?>
```
```