Quote:
Originally Posted by MarcoH64
PHP Code:
<?php
global $something;
foreach ($vbulletin->forumcache as $forumdata)
{
if ( strpos($forumdata["description"], '<!-- something -->') !== false )
{
$something[] = $forumdata["forumid"];
}
This will make the variable $something that is in the namespace of the calling script (ie. outside the function) accessible within the function.
|
This is what I understood about scope in PHP, so far.
Quote:
If the variable has not been defined/used yet it will be created implicit on the first use. If you now set $something to a value in your function, it will be accessible outside the function.
|
That is new to me. I did not realize that a function can create a variable and assign it scope outside of itself, if that's what you're saying. It's not something they emphasize in any of the documentation I've read.
Also, that raises a question about the plugin system. I was thinking that the my_mod.php file was being included, but it must be being executed within a call to the fetch_hook function. If the $global pushes the variable scope up to the calling context, then it makes sense. Do I have that right?
Am I reading that right, it is all done with plugins? No code hacks? I'm still allowed to talk to vbulletin.com??? :nervous:
That looks like exactly what I'm trying to do, Marco. Bless you!
I'll try the $global statement and get it working my way. Then I'll go back and do it the right way.

I don't mind finding out better ways to do what I've already done. The learning doesn't go away when I delete the dumb code!
Thank you for the help.
Be well,
Mike D.