1
dreamgear
custom block, type PHP
  • 2003/11/9 22:52

  • dreamgear

  • Friend of XOOPS

  • Posts: 78

  • Since: 2002/7/18


I wrote a php script that does a little "scraping" from another site and outputs some HTML, and I'm trying to use it in a custom block in XOOPS 2.0.5.

It doesn't seem to work.

I know the "fopen" works because some of the data is returned, but lots of other things go wrong, like my preg_match calls failing where they shouldn't, etc.

I ran the script in PHP command line mode on the hosting co's system and it works just fine.

Can anyone provide any hints on using PHP in custom blocks in general?

I'm wondering if XOOPS is changing some defaults that my script is depending on, and what they might be.

2
dreamgear
Re: custom block, type PHP
  • 2003/11/10 1:42

  • dreamgear

  • Friend of XOOPS

  • Posts: 78

  • Since: 2002/7/18


Is anyone using a custom block of type "PHP Script" for anything? I just spent a half hour looking through search results and it seems just about everybody finds them unusable.

What restrictions are there on the use of PHP in these blocks?

3
dreamgear
Re: custom block, type PHP
  • 2003/11/10 2:38

  • dreamgear

  • Friend of XOOPS

  • Posts: 78

  • Since: 2002/7/18


Well, here's one problem. Try this in a "PHP Script" block:

Quote:

function func_one ()
{
global $var_one;
print "I am func_one
\n";
print "var_one is: $var_one
\n";
}

$var_one = "Hello World";

print "I am main
\n";
print "var_one is: $var_one
\n";

func_one();


Why can't my function see $var_one ? Is there any way around this, other than passing all the globals in to the function?

4
dreamgear
Re: custom block, type PHP
  • 2003/11/10 3:27

  • dreamgear

  • Friend of XOOPS

  • Posts: 78

  • Since: 2002/7/18


Simple solution:

Quote:

global $var_one;

function func_one()
{
global $var_one;
print "I am func_one
\n";
print "var_one is: $var_one
\n";
}

$var_one = "Hello World";

print "I am main
\n";
print "var_one is: $var_one
\n";

func_one();


This does work, as expected. Problem solved.

Login

Who's Online

265 user(s) are online (160 user(s) are browsing Support Forums)


Members: 0


Guests: 265


more...

Donat-O-Meter

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

Latest GitHub Commits