Generate script html tag


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  1. /**
  2. * Generate line include src script
  3. * @param string $src : string with route from script
  4. */
  5. function link_script($src = '')
  6. {
  7. $index_page = FALSE;
  8. $type = 'text/javascript';
  9.  
  10. $CI =& get_instance();
  11.  
  12. $link = '<script ';
  13.  
  14. if ( strpos($src, '://') !== FALSE)
  15. {
  16. $link .= 'src="'.$src.'" ';
  17. }
  18. else
  19. {
  20. $link .= 'src="'.$CI->config->slash_item('base_url').$src.'"';
  21. }
  22. $link .= ' type="'.$type.'">';
  23.  
  24. $link .= '</script>';
  25. return $link;
  26. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.