- Moderated by:
- Support Team
-
- rank:
-
Softmore
- registered:
- November 2003
- Status:
- offline
- last visit:
- 20.03.06
- Posts:
- 54
Sure thing...
For example, I have a core/php block with the following:
Code
$testname = pnUserGetVar('name');
include("http://www.mysite.net/pn/index.php?module=Test");
Lets say modules/Test/index.php has the following:
Code
This should work right? -
- rank:
-
Softmore
- registered:
- November 2003
- Status:
- offline
- last visit:
- 20.03.06
- Posts:
- 54
Originally I had modules/Test/index.php with the following:
Code
and I had a core/php block with just this:
Code
include("http://www.mysite.net/pn/index.php?module=Test");
But, the block just ends up empty. If I go to the modules/Test/index.php
directly, the ouput is there. Any idea why it won't show in the block? -
- rank:
-
Moderator
- registered:
- March 2002
- Status:
- offline
- last visit:
- 26.08.08
- Posts:
- 7720
The problem is using an include via a URL. The way a URL based include works is different to the way a local include works and thus the scopes will be different. A local include will read the file and parse the source using the local PHP environment and will retain the variable scope. A remote include will only include the pre-parsed output since there is no way to remote get at the source of the include (nor should there be).
This is covered in the PHP include docs.
Thread moved to the development forums.
-Mark -
- rank:
-
Softmore
- registered:
- November 2003
- Status:
- offline
- last visit:
- 20.03.06
- Posts:
- 54
Thanks for the info. I didn't realize there was a difference between a URL include and a local include.
I've changed the include to this:
Code
include("modules/Test/index.php");
and all works great now. -
- rank:
-
Moderator
- registered:
- March 2002
- Status:
- offline
- last visit:
- 26.08.08
- Posts:
- 7720
In addition to variable scoping an include via http will be a lot slower since you've got to go all the way through the network layer (httpd, ip stack, NIC etc.) where as a local include is a simple file system access.
-Mark
