Useful PHP Snippets

If you are looking for useful PHP snippets, here’s list compiled from my previous posts. I am sure this list will come in handy for you in your PHP projects.

PHP $_GET & $_POST VariablesPHP MySqli Basic usage (select, insert & update)Send PHP mail with AttachmentCheck CURL is enabled in PHPGenerate Random String Using PHPDetect Ajax Request using PHPAdd Comments in PHPWorking with PHP SessionsSet Cookies Get Cookies Delete Cookies with PHPCreating PDF Files using PHP FPDF libraryHandle JSON data using PHPUpload a file with PHPResize Multiple Images in a Folder using PHPOutput Text on Image using PHPCache Dynamic Pages with PHPDate formats in PHPPHP Explode and ImplodeRedirect user to new URL with PHPRandomized quote display PHPPHP Pagination FunctionMicrosoft Access using PHP PDOReturn Currency Symbols using PHPForce download any file using PHPMake Plain text URLs clickable linksShorten URLs using API (PHP)Get domain name from email using PHPBlock Disposable email domains (PHP)Create New Widget in WordPressUseful PHP functions Copy/PasteBasic Adsense Plugin for WordPressOutput Text on Image using PHP imagettfbboxAmazon SNS Subscription verification with PHPGrab Picture From Remote URLUsing WordPress Custom FieldsFixing Image Orientation using its Exif dataCreating Valid RSS feed Using PHP DOMCreating RSS feed Using PHP SimpleXMLGet Percentage using PHPCreate Image Gallery from a DirectoryImage Upload and Re-size with PHPWatermark an uploaded Image with PHPCapture Array Values from Dynamic input Fields Combine JS or CSS files with PHPPHP $_GET & $_POST Variables10 Exceptionally Reliable PHP Snippets for DevelopersBackup MySQL Database Using PHP MySqliBackup Website and Database using PHP exec()Generate Username from User First and Last Name

15 Comments Add Comment

  • Great Job.., Keep Going…,Post a lot for web developers..,

  • Suhaib Ajaz Khan

    You’re a life saver!

  • Faruque Ahamed Mollick

    PHP snippets are often needed for developers to complete all types of projects. Thanks for writing great articles on several useful PHP snippets for us.

  • Hello Saran Chamling,

    This is a wonderful php tutorial collection. Thanks a lot. I need a simple php function which help me to display user online Ex.

    Online User: 100
    User: 20
    Guest: 80

    I want to add this information in my website Sidebar.

  • Hi Saran,
    Thanks a lot for shareing.
    So helpful.

  • thank you so much for this code

  • thank you so much for this code

  • Listing all your php tutorials in this proper manner is really good. :)

  • thank u so much for this code

  • Hi, your website is cool and educative. I would like if u could get time to make a tutorial on a php script that search the entire web pages for a match in a search bar. And should be able to work on the localhost without internet connection :-D
    Thanks hope to hear from u.

  • Well, what i could say is you are super awesome! Keep on the good work~

  • thanks a lot.. i learned a lot from your webs5te..
    more blessings.. thak you soooo much.. :D

  • To Sanwebe team,
    thanks a lot.. i learned a lot from your tutorials..
    more blessings.. thak you soooo much.. :D

  • Shahbaz Ahmed Bhatti

    Dear Sanwebe team,
    Bunch of thanks all o fyou people, for putting good tutorials related to php. this website is very nice and good and helpful


  • Hello! Please I would want to be able allow users select options from a list of selections as many times as possible using PHP, how do i achieve that? Below is a form for better description of what i desire to do

    You can enter your subjects as many times as possible




    Each time a user makes a complete entry, “Subject”-“Grade”-“Year”, the selection elements should re- appear to enable the user be able to make another selection as many times as possible, each time the user is doing this, the SELECTED should be visible for all to view.


This site uses Akismet to reduce spam. Learn how your comment data is processed.