Page 1 of 1

Problem with extern php script

Posted: Sun Dec 02, 2007 8:46 pm
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.

Re: Problem with extern php script

Posted: Sun Dec 02, 2007 10:28 pm
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

Posted: Mon Dec 03, 2007 10:04 am
by JuliusBeckmann
Thanks Garvin, that solved my Problem.

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