Problem with extern php script

Random stuff about serendipity. Discussion, Questions, Paraphernalia.
Post Reply
JuliusBeckmann
Posts: 2
Joined: Thu Jun 07, 2007 6:28 pm
Contact:

Problem with extern php script

Post by JuliusBeckmann »

Hi Forum.

I'am using Serendipity 1.1.2 and PHP 5.2.0-8+etch7

My problem is when i try to use this plugin 'serendipity_event_externalphp' to include my PHP scripts, they wont work properbly.

Here is a small example for an external PHP Script and my problem.

Code: Select all

<?php

$test = 'this is just a test';

// This echo works
echo  $test;

function example_test()
{ 
   global $test;

   // This echo does not work:
  echo $test;

}

example_test();


?>
I cant find my mistake.
Why does the echo in that function not work?

Thanks for reading this.
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: Problem with extern php script

Post by garvinhicking »

Hi!

The PHP is includedfromwithin a s9y PHP function. Thus you need to insert a "global $test" also at the very first line of your PHP code as well, not only within your function declaration.

Or you directly use $GLOBALS['test'] instead of $test everywhere.

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
JuliusBeckmann
Posts: 2
Joined: Thu Jun 07, 2007 6:28 pm
Contact:

Post by JuliusBeckmann »

Thanks Garvin, that solved my Problem.

I allready tried $GLOBALS[test] but it didnt work either.
Post Reply