Guest User

Untitled

a guest
Jan 23rd, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. <?php defined('BASEPATH') or exit('No direct script access allowed');
  2.  
  3. /**
  4. * Anchor Link
  5. *
  6. * Creates an anchor based on the local URL.
  7. *
  8. * @access public
  9. * @param string the URL
  10. * @param string the link title
  11. * @param mixed any attributes
  12. * @return string
  13. */
  14. if ( ! function_exists('anchor'))
  15. {
  16. function anchor($uri = '', $title = '', $attributes = '', $relative = FALSE)
  17. {
  18. $title = (string) $title;
  19.  
  20. if ( $relative === TRUE)
  21. {
  22. $site_url = is_array($uri) ? implode('/', $uri) : $uri;
  23. }
  24. elseif ( ! is_array($uri))
  25. {
  26. $site_url = ( ! preg_match('!^\w+://! i', $uri)) ? site_url($uri) : $uri;
  27. }
  28. else
  29. {
  30. $site_url = site_url($uri);
  31. }
  32.  
  33. if ($title == '')
  34. {
  35. $title = $site_url;
  36. }
  37.  
  38. if ($attributes != '')
  39. {
  40. $attributes = _parse_attributes($attributes);
  41. }
  42.  
  43. return '<a href="'.$site_url.'"'.$attributes.'>'.$title.'</a>';
  44. }
  45. }
Add Comment
Please, Sign In to add comment