Hi there,
i was searching for a solution to retrieve Variables in external PHP Files just like {PHP:my_ext.php?var=1} - there is a function in the forum but it messes up with other php includes.
So i have a very quick and very dirty hack:
In the content Element:
[PHP]
$var = 1
$relocate = "my_external.php"
include(relocate);
[/PHP]
IMPORTANT: 'relocate' is a file without file ending in the wcms root with the following content:
<?
include($relocate);
?>
So now, you have the $var available in my_external.php, and in any other external php file namend in $relocate.
Has Anyone another solution for this?
I tried everything, defining $GLOBALS wont work, but maybe I didn´t get the way PHPVAR works ...
Thank you
Variables in external PHP Files
Variables in external PHP Files
----------------
mfg
mfg
- Oliver Georgi
- Site Admin
- Posts: 9920
- Joined: Fri 3. Oct 2003, 22:22
- Contact:
If you use it that way it can not work.
all vars you are using have to be defined as global vars because all {PHP, {PHPVAR, [PHP is processed in separate functions - so vars you are set there are NON GLOBAL vars.
Vars you want to use anywhere has to be brought to the $GLOBALS array first.
You can try:
or
Oliver
all vars you are using have to be defined as global vars because all {PHP, {PHPVAR, [PHP is processed in separate functions - so vars you are set there are NON GLOBAL vars.
Vars you want to use anywhere has to be brought to the $GLOBALS array first.
You can try:
Code: Select all
global $myvar;
Code: Select all
$GLOBALS['myvar'] = 1;