You are here: How can I access other scopes (NOT global) « PHP Programming Language « IT news, forums, messages
How can I access other scopes (NOT global)

Posted by giblfiz on 01/07/08 17:47

I was hoping that someone on the group might have an idea of how to
access scopes (or symbol tables) other than the one you are currently
running in. (and no I don't mean global)

In particular, I'm trying to use register_tick_function, and have the
function that it calls be able to get at variables in the scope of
what (otherwise) would currently be executing. Unfortunately the scope
of the function called by register_tick_function seems to be it's
own.

An example in code:
<?php

function a(){
$my_a = "mystery_value";
b();
}

function b(){
echo($my_a); //doesn't work
}

a();
?>

So I'm trying to figure out how to get at $my_a, none of the obvious
(to me) solutions are viable, I can't simply pass $my_a to b because b
is being called by a tick. I can't store $my_a in the globals because
I don't get to modify any of the code in a(). (I would be more than
happy with a solution where all scope variables were pushed into
global, but I can't think of a way to do this.


I realize that what I'm trying to do runs against the grain of what is
supposed to be legal in a language. (the whole point of scopes is to
protect you from whats in your parents) but I'm really hoping there is
a solution anyway. Ideally I would like to do this without loading the
ADB module, but if there is something in there that will help, I'm
open to that idea as well.

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация