php question...

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
greenskyx
Forum Newbie
Posts: 1
Joined: Thu Mar 18, 2004 6:17 pm

php question...

Post 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!
Illusionist
Forum Regular
Posts: 903
Joined: Mon Jan 12, 2004 9:32 pm

Post 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()

?>
Post Reply