Category: General PHP

Regular Expressions Part 2 – Matching Patterns

Matching Patterns The preg_match() function performs Perl-style pattern matching on a string. preg_match() takes two basic and three optional parameters. These parameters are, in order, a regular expression string, a source string, an array variable which stores matches, a flag

Regular Expressions Part 1 – Introduction

In programming you quite often want to test a string for the occurrence of a character or group of characters. This is particularly true for such things as data validation on form input boxes. Regular expressions provide a pattern matching

Use regular expressions to validate PHP inputs

To help counter SQL injections you need to make sure that entered values use minimum character types as possible. So you restrict usernames to just a-z and 0-9 characters. To test for these, use something like : //—————————————————— /** *

Removing depreciated messages in PHP

To remove depreciated messages form displays you can use the ~E_DEPRECATED value in the error_reporting function something like the following : error_reporting(E_ALL & ~E_DEPRECATED & ~E_NOTICE);

A Shopping Cart using PHP Sessions

This posts illustrates a relatively simple shopping cart using PHP sessions to store the cart details, quantities and total cart amount. The cart has an ‘add to cart’, ‘remove from cart’ and displays the total value of the cart. This