WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDES  |  PHP CLASSES  |  CODE SEARCH  |  ARTICLES SEARCH  |  PHP FORUMS  |  PHP MANUAL  |  PHP FUNCTIONS LIST  |  WEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search
Submit a code Example / Snippet Submit Your Code
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
WeberDev's Monthly code contest PHP Code Contest
Your Personal Examples List My Favorite Examples
Your Personal Articles List My Favorite Articles
Edit Account Info Update Your Profile
PHP Code Search
Web Development Forums
Learn MySQL Playing Trivia
PHPBB2 Templates
Web Development Index
PHP Web Logs (BLogs)
Web Development Resources
Web Development Content
PHPClasses
PHP Editor
PHP Jobs
Vision.To Design
Ajax Tutorials
PHP Programming Help
PHP/MySQL Programming
Webmaster Resources
Webmaster Forum
XML meta language
website builder
Submit Site
Forex Trading Online forex trading platform

Go Back Add a Comment Send this example to a friend Add this Article to your personal favoritest for easy future access to your favorite Code Examples and Articles. Submit a code example Print this code example.
BACK ADD A COMMENT SEND TO A FRIEND ADD TO MY FAVORITES ADD CODE EXAMPLES PRINT
Title : Inline Scope Control - The inline class provides methods for creating and destroying local variable scopes. Simply put, local scopes are spaces where some or all of the global variables are temporarily hidden.
Categories : PHP, PHP Classes, Variables Click here to Update Your Picture
Zak Greant
Date : Feb 14th 2001
Grade : 2 of 5 (graded 5 times)
Viewed : 3526
File : No file for this code example.
Images : No Images for this code example.
Search : More code by Zak Greant
Action : Grade This Code Example
Tools : My Examples List

  Submit your own code examples 
 

<?php
/*
+----------------------------------------------------------------------+
| Copyright (c) 2000 J.A.Greant |
| (See end of file for usage notes and licensing information.) |
+----------------------------------------------------------------------+
*/

class inline
{
var $globals, $locals;

function inline ()
{
if (func_num_args ())
{
$vars = func_get_args ();

foreach ($vars as $var)
{
$var = trim ($var);
if (isset ($GLOBALS[$var]))
{
$this->globals[$var] = $GLOBALS[$var];
unset ($GLOBALS[$var]);
}
$this->locals[$var] = TRUE;
}
}
else
{
reset ($GLOBALS);
while (list ($key) = each ($GLOBALS))
{
if ($key != 'GLOBALS')
{
$this->globals[$key] = $GLOBALS[$key];

unset ($GLOBALS[$key]);
$this->locals[$key] = TRUE;
}
}
}
}

function get_global ($var)
{
if (isset ($this->globals[$var]))
return $this->globals[$var];

return NULL;
}

function get_globals ()
{
return $this->globals;
}

function export ($var)
{
if ($this->locals[$var])
{
$this->globals[$var] = $GLOBALS[$var];
return TRUE;
}

return FALSE;
}

function export_all ($var)
{
if (is_array ($this->locals))
{
reset ($this->locals);
while (list ($key) = each ($this->locals))
$this->globals[$key] = $GLOBALS[$key];
return TRUE;
}
return FALSE;
}

function exit_scope ()
{
/* Restore the global variables */
reset ($this->globals);

if (is_array ($this->globals))
while (list ($key) = each ($this->globals))
$GLOBALS[$key] = $this->globals[$key];

/* Destroy class variables */
unset ($this->globals);
unset ($this->locals);
unset ($this);
}
}
/*
+----------------------------------------------------------------------+
| FILE NAME: inline.pkg |
+----------------------------------------------------------------------+
| Author: J.A.Greant |
| Email : zak@nucleus.com |
| Date : 2000/11/23 |
+----------------------------------------------------------------------+
| The inline class provides a simple method for temporarily entering |
| local scopes for variables. The new scope can be restricted to a |
| few variables or (for debugging) the entire scope. This class is |
| most useful for debugging or for making emergency hacks to code. |
| |
| For example: Pretend that you are dealing with a large block of |
| obfuscated code and need to make it work in a very short amount of |
| time. Rather than worry about possible interactions with existing |
| variables, enter a local scope, do your quick hack and then return |
| the global scope. |
| |
| inline() method / class constructor |
| ----------------------------------- |
| Accepts a list of 0 or more variable names. All specified variable |
| names will be hidden until the exit_scope() method is called. If no |
| variable names are specified, then the entire global scope will be |
| hidden. |
| |
|--> WARNING: Hiding the entire global scope in this fashion is <--|
|--> both wasteful and bad coding style. It should really only be <--|
|--> used for debugging and emergencies. <--|
| |
| USAGE EXAMPLE: |
| // Create a local scope for variables $x, $y and $z |
| $my = new inline ('x', 'y', 'z'); |
| // do whatever you will with $x, $y and $z |
| // Return to global scope |
| $my->exit_scope (); |
| |
| get_global() method |
| ------------------- |
| Return the value of a hidden global variable. |
| |
| USAGE EXAMPLE: |
| // Create a local scope for variables $x, $y and $z |
| $my = new inline ('x', 'y', 'z'); |
| // do whatever you will with $x, $y and $z |
| // Find the global value of $x |
| print $my->get_global ('x'); |
| // Return to global scope |
| $my->exit_scope (); |
| |
| get_globals() method |
| -------------------- |
| Return the value of all hidden global variables. |
| |
| USAGE EXAMPLE: |
| // Create a local scope for variables $x, $y and $z |
| $my = new inline ('x', 'y', 'z'); |
| // do whatever you will with $x, $y and $z |
| // Find the global value of $x |
| print $my->get_globals (); |
| // Return to global scope |
| $my->exit_scope (); |
| |
| export() method |
| --------------- |
| Export a local variable to the global scope. |
| |
| USAGE EXAMPLE: |
| // Create a local scope for variables $x, $y and $z |
| $my = new inline ('x', 'y', 'z'); |
| // do whatever you will with $x, $y and $z |
| // Find the global value of $x |
| print $my->export ('x'); |
| // Return to global scope |
| $my->exit_scope (); |
| |
| export_all() method |
| ------------------- |
| Export all local variables to the global scope. |
| |
| USAGE EXAMPLE: |
| // Create a local scope for variables $x, $y and $z |
| $my = new inline ('x', 'y', 'z'); |
| // do whatever you will with $x, $y and $z |
| // Find the global value of $x |
| print $my->export_all (); |
| // Return to global scope |
| $my->exit_scope (); |
| |
| exit_scope() method |
| ------------- |
| Exit the local scope and destroy the class variables. |
| |
| USAGE EXAMPLE: |
| // Create a local scope for variables $x, $y and $z |
| $my = new inline ('x', 'y', 'z'); |
| // do whatever you will with $x, $y and $z |
| // Find the global value of $x |
| print $my->export ('x'); |
| // Return to global scope |
| $my->exit_scope (); |
+----------------------------------------------------------------------+

+----------------------------------------------------------------------+
|--> WARNING: Be careful if you nest scopes. Make sure to exit the <--|
|--> scopes in the reverse order that you called them. <--|
+----------------------------------------------------------------------+
| For Example: |
| // You should probably avoid this! :) |
| $x = 100; |
| $mine = new scope (); |
| $x = 10; |
| $yours = new scope (); |
| $x = 1; |
| $mine->exit_scope (); // $x will now equal 100 |
| $yours->exit_scope (); // $x will now equal 10 |
+----------------------------------------------------------------------+

+----------------------------------------------------------------------+
| CVS LOG INFO |
+----------------------------------------------------------------------+
$Log: inline.pkg,v $
Revision 1.2 2000/11/24 09:22:26 zak
Reworked code.
Added documentation and bsd-style license.

Revision 1.1 2000/11/24 08:09:04 zak
Initial commit of inline class

+----------------------------------------------------------------------+
| Copyright (c) 2000 J.A.Greant (zak@nucleus.com) |
| All rights reserved. |
+----------------------------------------------------------------------+
| Redistribution and use in source and binary forms, with or without |
| modification, is permitted provided that the following conditions |
| are met: |
+----------------------------------------------------------------------+
| Redistributions of source code must retain the above copyright |
| notice, this list of conditions and the following disclaimer. |
| |
| Redistributions in binary form must reproduce the above copyright |
| notice, this list of conditions and the following disclaimer in the |
| documentation and/or other materials provided with the distribution. |
| |
| Neither the name of the author nor the names of any contributors to |
| this software may be used to endorse or promote products derived |
| from this software without specific prior written permission. |
| |
| THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS |
| FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE |
| AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, |
| INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, |
| BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
| LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
| CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
| LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN |
| ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
| POSSIBILITY OF SUCH DAMAGE. |
+----------------------------------------------------------------------+
*/
?>



A class to put get and post variables in hidden form elements. Works on scalars, normal arrays, associative arrays.
Categories : Algorithms, Variables, Arrays, PHP, PHP Classes
file class , uploade file , download file already uploaded on another website
Categories : PHP, PHP Classes, Filesystem, Web Services
Authorize.net AIM Interface Class v1.0.0
Categories : PHP, PHP Classes, Ecommerce, Payment Gateways
A simple class with some HTML output functions that would come in handy for consistent page layout etc.
Categories : PHP, PHP Classes, HTML and PHP, HTML, Navigation
crop and resize image class using gd library function
Categories : PHP, PHP Classes, GD image library, Graphics
Excel class in PHP
Categories : PHP, PHP Classes, Excel
News management class
Categories : PHP, PHP Classes, Beginner Guides
The class to check load time of your script VERY usefull for relatively slow applications, but not only..
Categories : PHP, PHP Classes, Debugging
clearing variables in php3
Categories : Variables, Arrays, PHP
Expose - PHP template engine, supports server and client-sided caching,a plugin system, multiple languages, template script language is based on PHP itself.
Categories : PHP, PHP Classes, Templates, Complete Programs
Simple Template Class/Example
Categories : PHP, Templates, PHP Classes
RSS parser. Parses RSS into an array. Quick and nasty but does the job. No checking is done for correct Tags, only correct XML. PHP4 needed to display result (uses print_r).
Categories : PHP, XML, PHP Classes, Rich Site Summary (RSS)
MS Word Mail Merge Automation (COM)
Categories : PHP, PHP Classes, COM
Very minimal templating engine
Categories : PHP, PHP Classes, Templates
XPath for PHP without the DOM XML extension
Categories : DOM XML, XML, XSLT, PHP Classes, PHP