Page 1 of 1

php question...

Posted: Thu Mar 18, 2004 6:17 pm
by greenskyx
I have a setup like this (obviously this is stripped way down). I'm trying to write a plugin architecture for a cms that I'm building. Here is the situation I'm running into...

Code: Select all

function a(){
  $foo = '123'
  function b();
}

function b(){
  function c();
}

function c(){
   global $foo;
  print $foo;
}
Is there any way that you can make $foo in function c be able to be equal to '123' like it is in function a? If this is totally confusing, do you have any links to docs on how to write plugins/hooks into php applications?

Thanks!

Posted: Thu Mar 18, 2004 6:53 pm
by Illusionist
try this:

Code: Select all

<?php
function a(){
  global $foo;
  $foo = '123';
  b();
}

function b(){
  c();
}

function c(){
  global $foo;
  print $foo;
}

a()

?>