Starting a thread to share useful PHP functions.

Discussion in 'PHP' started by raj61184, Jan 22, 2011.

  1. #1
    Hi,

    As a developer life can be very easy if you can find ready made useful scripts, so I am starting a thread to share scripts which can be useful to everyone.

    here is one such method Bookmarking javascript

    <script type="text/javascript">

    function bookmarksite(title,url)
    {
    if (window.sidebar)
    window.sidebar.addPanel(title, url, "");
    else if(window.opera && window.print){
    var elem = document.createElement('a');
    elem.setAttribute('href',url);
    elem.setAttribute('title',title);
    elem.setAttribute('rel','sidebar');
    elem.click();
    }
    else if(document.all)
    window.external.AddFavorite(url, title);
    }

    </script>


    This method can be called like this:

    <a href="javascript:bookmarksite('your site titile', 'http://www.YourSite.com')"><strong>Liked it? Bookmark this site!</strong></a>


    Do share any such useful function you have.
     
    raj61184, Jan 22, 2011 IP
  2. raj61184

    raj61184 Member

    Messages:
    416
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    45
    #2
    This is a function to find a string between 2 strings:

    function get_string_between($string, $start, $end)
    {
    $string = " ".$string;
    $ini = strpos($string,$start);
    if ($ini == 0) return "";
    $ini += strlen($start);
    $len = strpos($string,$end,$ini) - $ini;

    return substr($string,$ini,$len);
    }
     
    raj61184, Jan 22, 2011 IP
  3. G3n3s!s

    G3n3s!s Active Member

    Messages:
    325
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    80
    #3
    raj, looks like good function :) (that second)
    but that first, what has that to do with PHP?

    However, good post ;)
     
    G3n3s!s, Jan 22, 2011 IP
  4. raj61184

    raj61184 Member

    Messages:
    416
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    45
    #4
    actually the title of the post should have been "useful scripts" not "useful PHP scripts" sorry for the typo :)

     
    raj61184, Jan 22, 2011 IP