These classes are based on a (slightly) improved set of classes and functions that were originally built on CodeAcademy and that we have found extremely useful. They can serve as a basis for not only UserSpice or for your project as a whole.

Usage

The Input class is a great way to grab data that is passed to your site, whether by get or post.

$permission = Input::get('name');

Notice that it is a static method and it needs the ::

The most important thing that the Input class does, however is automatically sanitize your data. Sweet. If you're getting input from a user, use it!

 

Input.php

If you copy and paste this code, please get rid of the space before the opening php tag.


<?php
class Input {
	public static function exists($type = 'post'){
		switch ($type) {
			case 'post':
				return (!empty($_POST)) ? true : false;
				break;

			case 'get':
				return (!empty($_GET)) ? true : false;

			default:
				return false;
				break;
		}
	}