#18864 [Com]: Nested Function within a class
| From: | pguillot at paanjaru dot com | Date: | Tue, 13 Aug 2002 09:28:42 +0000 |
| Subject: | #18864 [Com]: Nested Function within a class | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-16589@lists.php.net to get a copy of this message | ||
ID: 18864
Comment by: pguillot@paanjaru.com
Reported By: fathireza@yahoo.com
Status: Bogus
Bug Type: Class/Object related
Operating System: NT2000
PHP Version: 4.2.2
New Comment:
Dear Fathi,
I don't understand clearly what you want to do :
Your variable is
- recognized only in the function where it is defined
- recognized everywhere if it is __global__
It seems you want to create a class-global var !
(Q: in which real case is it useful ? )
Could'nt you pass the var when calling your last function ?
Anyhow, thanks to all for the dev, support and use cases ... After so
much time using Php, i'm still amazed by it's power and speed (imho).
Patrick
Previous Comments:
------------------------------------------------------------------------
[2002-08-13 04:06:34] rasmus@php.net
What are you talking about? Run this:
<?
class A {
var $someX;
function b() {
}
function c() {
$this->someX=1;
}
}
$foo = new A;
$foo->c();
echo $foo->someX;
?>
------------------------------------------------------------------------
[2002-08-13 04:02:41] fathireza@yahoo.com
Well dear rasmus what you said is totally meaningless. Try
to access "this" variable in any order of function calling
that you wish, but it is not accessible in any case.
These comments are worthless and does not solve the scoping
problem with php 4.2.2.
Thanks..
R. Fathi
------------------------------------------------------------------------
[2002-08-13 03:56:14] rasmus@php.net
There is absolutely no difference between:
function b() {
function c() {
}
}
and:
function b() { }
function c() { }
in terms of their calling scope. They are identical. It's not like
function c won't be defined until function b is called in the first
case. So what you are doing is meaningless.
------------------------------------------------------------------------
[2002-08-13 03:36:10] fathireza@yahoo.com
"Why would you need this functionality?" does not really
answer my question/problem.
Anyhow there is a reason for it and I am developing some
reusable classes for the project I am working on.
Thanks...
Anyhow
------------------------------------------------------------------------
[2002-08-13 01:03:30] kalowsky@php.net
Why would you need this functionality? Why not just create a second
function within the class, and call it there?
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
http://bugs.php.net/18864
--
Edit this bug report at http://bugs.php.net/?id=18864&edit=1