i have code , works perfectly:
if(in_array($_server['http_host'], array('localhost', '127.0.0.1'))) // localhost { $root = ''; } else { if(!empty($_server['https'])) // https { $root = 'https'.'://'.$_server['https_host']; } else // http { $root = 'http'.'://'.$_server['http_host']; } }
i echo way:
<img src="<?php echo $root.htmlspecialchars($path, ent_quotes); ?>" />
i want wrap code inside function like:
function root() { // code }
and echo similar way this:
<img src="<?php echo root().htmlspecialchars($path, ent_quotes); ?>" />
how it? because example doesn't work. :(
your function doesn't return value, there's nothing echoing... try adding return $root
@ end of function:
function root() { //that code return $root; }
Comments
Post a Comment