Last active
December 18, 2015 13:09
-
-
Save gravataLonga/5787886 to your computer and use it in GitHub Desktop.
site_url in php.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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