Class Name: ReturnVars
Date Created: 9/19/06
Author: Chase Spell
Purpose: Stores variable/value pairs in an associative
array. Echos the final product as a url-encoded string
formatted as a GET request. Intended to be used
to return data from a php script to a Flash movie, but
could be used for any system that accepts GET statements for input.
By : Syntax
/****************************************
Class Name: ReturnVars
Date Created: 9/19/06
Author: Chase Spell
Purpose: Stores variable/value pairs in an associative
array. Echos the final product as a url-encoded string
formatted as a GET request. Intended to be used
to return data from a php script to a Flash movie, but
could be used for any system that accepts GET statements for input.
*****************************************/
class ReturnVars {
var $CurrentVars;
var $Vars = array();
function __construct() {
//Properties
$this->CurrentVars = 0; //Number of Var/Val pairs in the "Vars" array
}
//Methods
//Adds a new var/val pair to Vars and updates CurrentVars
function AddVar($name,$value) {
//if ($name != "" && $value != "") {
$this->Vars[$name] = $value;
$this->CurrentVars = $this->CurrentVars + 1;
//}
}
//Removes var/val pair from Vars array, $name corresponds to an existing variable name in the array
function RemoveVar($name) {
if (array_key_exists($name,$this->Vars)) {
unset($this->Vars[$name]);
$this->CurrentVars = $this->CurrentVars - 1;
}
}
//For/Each loop goes through Var adding each pair to a string in this format: "(var)=(value)&" and
//and echos that string for output
function PrintData($printandexit = true) {
$output = "";
if ($this->CurrentVars > 0) {
foreach ($this->Vars as $var => $val) {
$output .= urlencode($var)."=".urlencode($val)."&";
}
echo $output;
} else {
echo "No data was returned.";
}
if ($printandexit = true) {
exit;
}
}
}
| DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware. |
More Miscellaneous Code Articles
More By Codewalkers
developerWorks - FREE Tools! |
This tutorial discusses the concepts of REST and the Atom Publishing Protocol (APP) and shows how they apply to services. It also shows how to use Java technology to implement REST/APP-based services. FREE! Go There Now!
|
|
|
|
Here's a fun way to learn about DB2! Learn or teach the basics of DB2 and relational database with an interactive game called The DB2 Detective Game. The game teaches relational database concepts and shows how technology can be applied to solving real-life problems (the game's theme is a crime investigation). This tutorial has been updated for DB2 9. FREE! Go There Now!
|
|
|
|
Join this Rational Talks to You teleconference on December 6 at 1:00 pm ET to participate in an agile application development discussion and get your questions answered on using IBM Rational Method Composer in a distributed environment.Get your questions answered! FREE! Go There Now!
|
|
|
|
Join this Rational Talks to You teleconference on November 29 at 1:00 pm ET to participate in an interactive discusssion with Grady Booch around architecture and reuse. Get your questions answered! FREE! Go There Now!
|
|
|
|
In this tutorial, you can learn how to install and configure the IBM Rational Asset Manager Eclipse client, explore the different views in the Asset Management perspective, learn various search techniques, work with existing assets, and submit a new asset. FREE! Go There Now!
|
|
|
|
User communities play an important role in communication and collaboration around products, solutions and other areas of special interest to members. Successful communities are able to provide the right mix of content and services to deliver a value proposition that resonates with each audience. Join Tom Inman, VP of Marketing for Information and Platform Solutions as he introduces the new LeverageINFORMATION community. During this webcast, learn about the value provided by the community and how customers and partners derive value from the community in addressing their own technical and business challenges. FREE! Go There Now!
|
|
|
|
Building a software-as-a-service solution requires addressing a few key technical challenges. In this webcast, we'll focus on the role of IBM Tivoli Directory Server and WebSphere Portlet Factory in creating a Software as a Service solution. We will demonstrate how to use Tivoli Directory Server to prevent the user population of one tenant from accessing the virtual portal and portlet components of another tenant. We will also use the dynamic profile capability of WebSphere Portlet Factory to create multiple highly customized applications from one code base. FREE! Go There Now!
|
|
|
|
Hear how IBM Rational Project and Portfolio Management integrated solutions help teams put the right tools and processes in place to maximize the effectiveness and efficiency of project teams and ensure that the business vision is being executed correctly. Learn how to automate and integrate requirements prioritization, top-down project planning, communications and controls, and methodology deployment to keep your scope, costs, and schedules under control. Tackle with an end-to-end approach the management of scope and scope changes, usage of methodology to control and empower project teams, and optimization of resources to align activity costs with the overall project plan. FREE! Go There Now!
|
|
|
|
Achieving true agility is a never-ending effort. We will showcase how you can become agile incrementally, a few practices at the time.Which practices should any agile team strive to adopt? What additional practices should you consider based on your needs to scale? Adopting practices are however made much easier with the right tool support. What about if your tools adapt to your practices? We will take a look at how the Jazz technology can be leveraged to make your process change the behavior of your tools. FREE! Go There Now!
|
|
|
|
The Eclipse community is constantly working to extend Eclipse's functionality. In this webcast, learn about some of the most important and feature-rich projects under development. From multi-language support to plug-in development, tune in to see what Eclipse is capable of now. FREE! Go There Now!
|
|
|
|
All FREE IBM® developerWorks Tools! |