|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2002-08-12 04:07 UTC] fathireza at yahoo dot com
Hello,
I have no access to "this variable" within the nested function.
class A{
var someX;
function b()
{
function c()
{
$this->someX=1;
//Error this variable unknow here
}
}
}
Best regards...
R. Fathi
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Nov 07 18:00:01 2025 UTC |
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.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; ?>Dear Rasmus, This is what I am basically trying to do. If there is anything wrong with this, please let me know. This is what I get Notice: Undefined variable: this in c:\inetpub\wwwroot\phpsite\testthis.php on line 17 Thanks.. R. Fathi <?PHP class A { var $someX; function A($str) { //...... $this->b($str); } function b($num) { $func="c_".$num; $this->someX=1; function c_1() { //Error this variable unknow here print "$this->someX"; } function c_2() { } //.... $func(); } } $foo = new A("1"); ?>