NYCPHP Meetup

NYPHP.org

[nycphp-talk] require/include inside a function

Hans Zaunere zaunere at yahoo.com
Thu Jun 13 21:27:00 EDT 2002


Yeah, exactly right.  Drat.

Thanks,

HZ


--- "Nunez, Eddy" <enunez at tiaa-cref.org> wrote:
> 
> I believe functions and class definitions are globally scoped.
> I think the local scoping only applies to variables.
> 
> I exec'd this bit of code and it supports my statement:
>
-----------------------------------------------------------------------
> function definer() {
>         include_once("./foo.inc");
>         function func_foo() { echo 'foo was here'; }
> }
> 
> echo ( class_exists( 'foo' ) ) 
> 	?  'foo is out there!' : 'foo not there.'; print "<br>";
> echo ( function_exists( 'func_foo' ) )
> 	?  'func foo is out there!' : 'func foo not there.'; print "<br>";
> 
> definer();
> 
> echo ( class_exists( 'foo' ) )
> 	?  'foo is out there!' : 'foo not there.'; print "<br>";
> echo ( function_exists( 'func_foo' ) )
> 	?  'func foo is out there!' : 'func foo not there.';
>
-----------------------------------------------------------------------
> Output:
> foo not there.
> func foo not there.
> foo is out there!
> func foo is out there!
>
-----------------------------------------------------------------------
> 
> Hope this helps.
> -Eddy
> 
> -----Original Message-----
> From: Hans Zaunere [mailto:zaunere at yahoo.com]
> Sent: Monday, June 10, 2002 10:18 PM
> To: NYPHP Talk
> Subject: [nycphp-talk] require/include inside a function
> 
> 
> 
> I'm using the unserialize_callback_func ini setting, from
> http://www.php.net/manual/en/function.unserialize.php like so:
> 
> ini_set('unserialize_callback_func','handlestdclass');
> 
> function handlestdclass( $classname ) {
>    require_once("{$classname}/{$classname}.inc");
> }
> 
> Now I may be overlooking something very obvious, but when code is
> require/included in a function, it is locally scoped inside that
> function.  If that's the case, and no way around it, what good is
> this
> directive?
> 
> Any thoughts would be helpful.  Thanks guys,
> 
> Hans Z
> 
> __________________________________________________
> Do You Yahoo!?
> Yahoo! - Official partner of 2002 FIFA World Cup
> http://fifaworldcup.yahoo.com
> 
> 
>
**********************************************************************
> This message, including any attachments, contains confidential
> information intended for a specific individual and purpose, and is
> protected by law.  If you are not the intended recipient, please
> contact sender immediately by reply e-mail and destroy all copies. 
> You are hereby notified that any disclosure, copying, or distribution
> of this message, or the taking of any action based on it, is strictly
> prohibited.
> TIAA-CREF
>
**********************************************************************
> 


__________________________________________________
Do You Yahoo!?
Yahoo! - Official partner of 2002 FIFA World Cup
http://fifaworldcup.yahoo.com



More information about the talk mailing list