Skip to content

Instantly share code, notes, and snippets.

@gravataLonga
Last active December 18, 2015 13:09
Show Gist options
  • Save gravataLonga/5787886 to your computer and use it in GitHub Desktop.
Save gravataLonga/5787886 to your computer and use it in GitHub Desktop.
site_url in php.
<?php
require 'site_url.php';
echo site_url(array('blog','como-criar-url'));
// output: http://www.jonathanfontes.pt/blog/como-criar-url
echo site_url('blog/como-criar-url');
// output: http://www.jonathanfontes.pt/blog/como-criar-url
<?php
define('BASE_URL','http://www.jonathanfontes.pt');
function site_url ( $path = '')
{
if( is_array( $path ))
{
return BASE_URL.'/'.(implode('/', $path));
}else if( is_string ( $path ) )
{
return BASE_URL.'/'.ltrim($path,'/');
}
return BASE_URL;
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment