PHP Classes

File: example.php

Recommend this page to a friend!
  Classes of Kenaniah Cerny   Query String Manager   example.php   Download  
File: example.php
Role: Example script
Content type: text/plain
Description: Example File
Class: Query String Manager
Manipulate query strings
Author: By
Last change:
Date: 15 years ago
Size: 1,478 bytes
 

Contents

Class file image Download
<?php

require_once "query_string.php";

$qs = new Query_String; //By default, our object will be populated from $_GET

//Print our current query string
print "<h2>Initial query string:</h2><p><a href='".$qs."'>".$qs."</a></p>";

//Add a few variables to our query string
$qs->page = rand(1, 12);
$qs->sort = "ascending";
$qs->filter = "yes";

//Print out a new version of our query string
print "<h2>Modified query string:</h2><p><a href='".$qs."'>".$qs."</a></p>";

//Change a few more variables in the query string
$qs->sort = "descending";
unset(
$qs->page);
unset(
$qs->timestamp);

//Print out a new version of our query string
print "<h2>Query string without page or timestamp:</h2><p><a href='".$qs."'>".$qs."</a></p>";

//Add more data to the query string
$qs->timestamp = time();

//Print out a new version of our query string
print "<h2>Modified query string with timestamp added:</h2><p><a href='".$qs."'>".$qs."</a></p>";

//Start over from scratch
$qs->set_array( array() );
$qs->boolean = false; //TRUE and FALSE are automatically converted into text by the class

//Print out a new version of our query string
print "<h2>Reset query string and added a boolean value:</h2><p><a href='".$qs."'>".$qs."</a></p>";


//The above examples use $qs->__toString() to generate the printed text.
//Alternately, you can use $qs->url() to generate the query string without the HTML-escaped ampersands (perfect for location redirects)
?>