1
Freeflier
Global variables in PHP scripts
  • 2004/12/12 10:01

  • Freeflier

  • Just popping in

  • Posts: 2

  • Since: 2004/12/12


I'm sorry if this has been answered elsewhere, but I haven't found it.

I'm trying to use php script includes in custom blocks and running into trouble with global variables. The scripts that I am using work fine when run on their own but when included in a custom block, the globals seem to disappear.

For example:

Including a php file with the following code in it
----
$text = 'Hello World';
echo $text;
----
Will produce the output 'Hello World'.

And including a php file with the following code
----
$text = 'Hello World';

function display() {
global $text;
echo $text;
}

display();
----
Produces no output.

Both scripts run outside the XOOPS environment produce the output 'Hello World'.

Thanks in advance for any help.
---------------------------------
- Blue Skies and Stay Vertical! -
---------------------------------

Login

Who's Online

260 user(s) are online (57 user(s) are browsing Support Forums)


Members: 0


Guests: 260


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Sep 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits