Category: Code Snippets

PHP Code Snippets
John Morris

Send PHP Email Using PHPMailer

PHPMailer is a popular open source, email-sending library used by applications like WordPress, Drupal, SugarCRM, Joomla and others. This tutorial will show you how to install PHPMailer, set up SMTP and send email in PHP using PHPMailer.

Read More »
PHP Code Snippets
John Morris

PHP Add To and Remove Elements From an Array

In this tutorial, I’ll show you eight different ways to add to, remove from and insert elements to/from an array in PHP. PHP array functions used include: array(), array_push(), array_unshift(), array_pop(), array_shift(), array_slice(), count(), array_diff() and array_splice().

Read More »
PHP Code Snippets
John Morris

What object-oriented programming is NOT

Object-oriented programming is MORE (much more) than knowing how to write a class. It’s about how you build your applications. I call it an “approach”… but it’s an approach *to application-building*.

Read More »
PHP Code Snippets
John Morris

Connecting to MySQL with PDO

With MySQLi, it looks like this: $mysqli = new mysqli($db_host, $db_user, $db_pass, $db_name); But, PDO is a bit different because it can interact 12 different

Read More »
PHP Code Snippets
John Morris

Simple input filtering in PHP

Here’s one I don’t see talked about much: $name = filter_input(INPUT_POST, ‘name’, FILTER_SANITIZE_STRING); What this does is grab the “name” element from your POST array

Read More »
PHP Code Snippets
John Morris

PHP cURL Tutorial and Example

A simple PHP cURL tutorial and example. Learn how to use curl_init, curl_setopt, and curl_execute. Also learn how to POST data to a remote URL

Read More »
Close Menu