[PHP] Accessing a variable from inside a local function

2004-07-28 Thread Frank Munch
Would anyone know how to resolve this scope problem? Or is this possibly 
something PHP can't (yet) do?

The problem is to access a variable in a function foo from a function local 
to foo.

- - -
function foo($var_foo)
  {
  $my_foo_local = 10;  //How can I reach this from inside function bar(...?
  function bar($var_bar)
{
return $my_foo_local+$var_bar+1;  //  Doesn't work,  can't see 
$my_foo_local
}

  return bar($var_foo)+1;
  }
if (foo(0)==12)
  echo Yes! I did it!;
else
  echo Nope. Sorry;
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Re: Accessing a variable from inside a local function

2004-07-28 Thread Frank Munch
Thanks for the good suggestion, a fully usable workaround if a cleaner 
thing doesn't surface.

And for your response time.. well, I have had slower answers in 
phone-conversations... :-)

At 06:37 PM 7/28/2004, Jason Barnett wrote:
Something like this is probably better handled by a class.  Then you can 
access class properties to do what you want.

Class yourclass
{
  function foo()
  {
$this-my_foo_local = 10;
  }
  function bar($var_bar)
  {
return $this-my_foo_local+$var_bar+1;
  }
}
$object = new yourclass();
$object-foo();
echo $object-bar(12);
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


RE: [PHP] Accessing a variable from inside a local function

2004-07-28 Thread Frank Munch
At 07:39 PM 7/28/2004, Ford, Mike   [LSS] wrote:
Actually, your problem is that the function bar is *not* local to foo.  Even
though PHP lets you declare functions lexically within the scope of other
functions
snip
Ouch! Thanks! Got that much wiser! So for keeping the namespace cleaner 
using classes is the only way.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Using Post like Get

2004-07-23 Thread Frank Munch
Hi,
a cookie is path-specific - can that help you?
Frank

At 10:54 PM 8/23/2004, you wrote:
What I'm trying to achieve is to have the same cookie IDENTIFY a user on 
different (or same) applications (on the same server), but require them to 
log in for each application, and get a different session.. Basically, to 
keep separate 'user trails and in process variables' for different tabs or 
windows in a browser.

www.scotttrade.com does it somehow, and I see no GET variables on the URL.
John W. Holmes wrote:
Dennis Gearon wrote:
With get varaibles, it's possible to always have get variables on a 
page, even without a form, by simply appending the Get variables to the 
end of the URL.

Is there anyway to do the same with Post variables? For instance, a 
javascript that onUnload submit, or something?

You can't just include POST variables in a link, if that's what you're 
going for. Perhaps some clunky javascript submitting a hidden form on an 
onclick method would get you close, but why even bother?

Maybe you should just say what you're actually trying to achieve and why, 
then we could offer better alternatives.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Re: Project-browser-function / required/included

2004-07-22 Thread Frank Munch
Hi,
thanks for your comment. Right, and similarly, it struck me that in case 
there are variable-names in the path, like in

require_once $my_lib_dir . some_funcs.php;
the variable $my_lib_dir could only be known at run-time and not by any 
simple script just scanning the source.

Still, it would be possible to deliver a variable_name=value  to the 
traversing function which would be good enough in most cases.

May get around to it one day...
Frank

At 06:46 PM 7/22/2004, Jason Barnett wrote:
Hmmm... this may be difficult to implement.  For simple include/require 
trees it could be done quite easily... but __autoload opens up a whole 
other bag of worms.  But now that I think of it I suppose you could create 
Reflections and get the location of class defintions from that.  This 
might fit with something else I'm working on, I'll report back here if I 
come up with something useful.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Project-browser-function / required/included

2004-07-21 Thread Frank Munch
Hello,
it would be nice to get a list of all required/included-files in a project.
Would anyone know of such a tool, e.g. a PHP-function that would take a 
filename as input and then recursively scan for the tree of 
required/included files?

Also HTML-links (A HREF...) and similar would be nice to be able to see - 
i.e. a function that takes a file as input and recursively checks for all 
links.

TIA!
Frank
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] exec/system question..

2004-07-21 Thread Frank Munch

On Wed, 21 Jul 2004 10:09:52 -0700, bruce [EMAIL PROTECTED] wrote:

 2) i could run the perl script, and have it somehow run in the
 background this would ba good, if there's a way to essentially run the
 php script in the background such that it doesn't hang apache.
Do you mean ...to essentially run the PERL script in the background...
If so you can just use the info in the manual: function.exec.html:
Note: If you start a program using this function and want to leave it 
running in the background, you have to make sure that the output of that 
program is redirected to a file or some other output stream or else PHP 
will hang until the execution of the program ends. 

i.e.
?php
...
exec(/my/perlscript  /my/dump.txt 21);
...
?
This will have your PHP script continuing without waiting for the perl script.
- - -
...If I understood you correctly.
HIH.
Frank

i'd like to
 kick off the php, and have the php/web app return. i could set some form of
 session var to trigger off of when the php is complete..

 any thoughts/pointers/etc...

AFAIK there's no way to do this. When the request ends (user hits
stop, exit or die called) the process is ended. This includes
children. If you could set it off asynchronously, there would be no
way of knowing when it ended as the process wouldn't have access to
that session any more.
I would suggest setting a value in a table and have a cron job check
for those values, run the script if it's supposed to, then update the
table with the results. Then the PHP script can check the table to see
it it's done.
--
DB_DataObject_FormBuilder - The database at your fingertips
http://pear.php.net/package/DB_DataObject_FormBuilder
paperCrane --Justin Patrin--
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Function with Optional Arguments

2004-07-21 Thread Frank Munch
You can use default arguments:
func foo($first, $second=2, $third=3 etc.
or look at
function func_num_args(...
HIH
Frank
At 01:39 AM 7/22/2004, Alex Hogan wrote:
Hi All,
How do I write a function with optional arguments?  Is it possible in
php?
function myfunc($First, $Second,[$Third, $Fourth]){
some stuff here
}

alex hogan


*
The contents of this e-mail and any files transmitted with it are 
confidential and
intended solely for the use of the individual or entity to whom it is 
addressed. The
views stated herein do not necessarily represent the view of the company. 
If you are
not the intended recipient of this e-mail you may not copy, forward, 
disclose, or
otherwise use it or any part of it in any form whatsoever. If you have 
received this
e-mail in error please e-mail the sender.
*
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php