PHP Classes

File: example.php

Recommend this page to a friend!
  Classes of MC Breit   ENV Vars   example.php   Download  
File: example.php
Role: Example script
Content type: text/plain
Description: A simple example is playing around..
Class: ENV Vars
Load, save and manage environment variables
Author: By
Last change:
Date: 17 years ago
Size: 2,501 bytes
 

Contents

Class file image Download
<?php
/***************************************************************************
 * ENV Vars Class Example
 * ----------------------
 * begin : Sunday, Nov 09, 2004 - 17:00
 * copyright : (C) 2004 MC Breit
 * email : support@mcb.cc - MCB.CC - The Coding Company
 * last modified : 09/11/04 - 18:35 - MC Breit
 * version : 1.0.0
 *
 ***************************************************************************/

/***************************************************************************
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 ***************************************************************************/

/***************************************************************************
 *
 * This example just is playing around with some variables, savong them,
 * load them again, protect them and so on..
 * There are no futher examples because use of this class is so easy ;-)
 *
 ***************************************************************************/

//
// Example of use..
//

//Include teh main class..
include('./env_vars.class.php');

//TEXT/PLAIN header..
header('Content-Type: text/plain');

//New env_var handle..
$env = new env_vars();

//Setting some env vars..
$env->set_env_var('FOO', 'BAR');
$env->set_env_var('FAZ', 'BAZ');

//Protect FOO from change..
$env->protect_env_var('FOO');

//Print out a list of all env_vars..
print $env->list_env_vars();

//Save the env vars and print out something..
$env->save_env_vars(dirname(__FILE__).'/.env.php') or die('Error saving ENV Vars');
print
"Env vars saved..\n";

//New env vars object..
$env2 = new env_vars();

//Load the env vars from $env..
$env2->load_env_vars(dirname(__FILE__).'/.env.php') or die('Error loading ENV Vars');

//Check up that FOO is still protected..
if( $env2->is_protected_env_var('FOO') )
{
  print
"FOO is still protected!\n";
}
else
{
  print
"FOO is not protected yet\n";
}

//List env vars a last time..
print $env->list_env_vars();

//Delete FAZ
$env->set_env_var('FAZ');

//Now FAZ should be empty..
print $env->get_env_var('FAZ');

//
// Thats it folks!
//
?>