Creating an URL without global variables
<p>I have a code like this below, which gives me a <strong>$link</strong> that equals to: <strong>http://mydomain.com/image/photo.JPG</strong></p>

<pre><code>if (!empty($_SESSION['item'][$i]))
{
    $path = dirname(__FILE__).'/image/'.basename($_SESSION['item'][$i]);
    if (move_uploaded_file($_SESSION['item'][$i], $path)) 
        global $url;

    if ( $url )
    {
        $link = $url.'/image/'.basename($_SESSION['item'][$i]);
        echo "&lt;td&gt;&lt;img src='" . $link . "' width='50' height='50' /&gt;&lt;/td&gt;";
    }
}
</code></pre>

<p>I wonder, how should I properly ommit using global variable here to achieve the same result.</p>

<p><strong>UPDATE</strong></p>

<pre><code>if (move_uploaded_file($_SESSION['item'][$i], $path))
{
    $link = 'image/'.basename($_SESSION['item'][$i]);  
    echo "&lt;td&gt;&lt;img src='" . $link . "' /&gt;&lt;/td&gt;";
}
</code></pre>

<p>This modification doesn't show any letter. It seems that if block doesn't execute.</p>
