Login   Register  
PHP Classes
elePHPant
Icontem

File: example.custom_modes.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Joshua Townsend  >  Request Data  >  example.custom_modes.php  >  Download  
File: example.custom_modes.php
Role: Example script
Content type: text/plain
Description: Example of using custom modes to point to your own data
Class: Request Data
Retrieve and process request parameters
Author: By
Last change:
Date: 7 years ago
Size: 1,021 bytes
 

Contents

Class file image Download
<?php
// Using custom modes
require "request.class.php";

$request = new request();

$request->add_mode("x"$_SESSION); // Add session as the mode "x".  Note that "s" is already taken by $_SERVER
$time $request->get_int("logged_time""x"); // Example of getting data from $_SESSION using same syntax as other variables
$request->remove_mode("x"); // mode "x" no longer needed

// You could also do this:
$request->allow_mode_override(true);
$request->add_mode("s"$_SESSION);
$time $request->get_int("logged_time""s");
$request->remove_mode("s");

$exampledata = array("id" => "5""username" => "jsmith"); // Example data, such as that about a user

$request->add_mode("u"$exampledata); // Add user data as the mode "u"
$id $request->get_int("id""u"); // Example of getting data from $exampledata using same syntax as other variables

$request->set_default_mode("u");
$id $request->get_int("id"); // Now "id" comes from mode "u", because second parameter was equivalent to null
?>