The list below is a compilation of list of some useful code snippets which might help you when writing your awesome PHP scripts.
Also: See more PHP Scripts
1. Email address check
The aim of this project is to create an email address validation class (or function) that checks for technical validity1 in email addresses, the idea being then that a site can send an email to that address to verify ownership.
2. Random password generator
Is a complete, working random password generation function for PHP. It allows the developer to customize the password: set its length and strength. Just include this function anywhere in your code and then use it.
3. Get IP address
Returns the real IP address of a visitor, even when connecting via a proxy.
4. XSL transformation
This tutorial is for developers who wish to know how to generate HTML documents using a combination of XML data and XSL stylesheets. PHP5 version.
5. Force downloading of a file
Forces a user to download a file, for e.g you has an image but you want the user to download it instead of displaying it in his browser.
6. String encoding to prevent harmful code
7. Sending mail
Using PHPMailer. PHPMailer a powerful email transport class with a big features and small footprint that is simple to use and integrate into your own software.
8. Uploading of files
Using class.upload.php from Colin Verot.
9. List files in directory
List all files in a directory and return an array.
10. Querying RDBMS with MDB2 (for e.g MySQL)
PEAR MDB2 provides a common API for all supported RDBMS.
Using Redis with Node.js
By Ivaylo Gerchev,
Need fast data interactions in your Node app? Learn how Redis speeds caching, message brokering, sessions, analytics, streaming and more.
Build a Website with React and Tailwind CSS
By Shahed Nasser,
React and Tailwind CSS: a beautiful relationship! Learn how Tailwind frees you from writing CSS so you can focus on your React components.
React Fragments: A Simple Syntax to Improve Performance
By Antonello Zanini,
React fragments provide a simple syntax to group a list of HTML elements without adding unnecessary nodes to the DOM. Here's how.
Sam Deering has 15+ years of programming and website development experience. He was a website consultant at Console, ABC News, Flight Centre, Sapient Nitro, and the QLD Government and runs a tech blog with over 1 million views per month. Currently, Sam is the Founder of Crypto News, Australia.