note 56643 added to function.include
| From: | phpguy at excludme dot mailstop dot yogelements dot com | Date: | Sat, 10 Sep 2005 18:33:48 +0000 |
| Subject: | note 56643 added to function.include | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-94995@lists.php.net to get a copy of this message | ||
On navvywavvy's not of 27-Aug-2005 02:53:
re: include'd/require'd function/method
does not see class property's/variable's
I just ran into this and after reading your solution-less description of the problem I decided to
simply try passing the properties I needed to the included method by reference and it works just
fine. I also tried passing the whole class space via $this and that works fine too.
Note that i was also include()ing and referencing the included method FROM a method, in fact the
constructor in this case.
example class code:
<?php
class myclass {
var $samplevar;
function myclass() {
this->sample="value":
include('sampleinclude.incl');
samplemethod($this->samplevar);
}
}
?>
example sampleinclude.incl
<?
function samplemethod(&$samplevar) {
echo $samplevar;
}
?>
displays: value
I also tried to include/require sampleinclude.incl from classes globalspace ie outside of any
method, thinking that I could then use $this->samplemethod() but it wouldn't let me.
----
Manual Page -- http://www.php.net/manual/en/function.include.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+56643
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+56643&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+56643&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+56643&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+56643&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+56643&report=yes&reason=non-english
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+56643&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+56643&report=yes
Search -- http://master.php.net/manage/user-notes.php