Creating an URL without global variables
Posted
by dygi
on Stack Overflow
See other posts from Stack Overflow
or by dygi
Published on 2010-03-30T13:38:59Z
Indexed on
2010/03/30
13:43 UTC
Read the original article
Hit count: 391
I have a code like this below, which gives me a $link that equals to: http://mydomain.com/image/photo.JPG
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 "<td><img src='" . $link . "' width='50' height='50' /></td>";
}
}
I wonder, how should I properly ommit using global variable here to achieve the same result.
© Stack Overflow or respective owner