Ravens PHP Scripts: Forums
 

 

View next topic
View previous topic
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> RavenNuke(tm) v2.5x
Author Message
neralex
Site Admin



Joined: Aug 22, 2007
Posts: 1512

PostPosted: Thu May 02, 2013 7:21 am Reply with quote

It seems my blond-mode was activated... lol

I have tried to create a block and for that i want use some functions from a module. In this way i have called the file that contains the functions with require_once. To use the functions i need some variables, so i have added the variables before i call my functions file. But without luck!

Why i can not use own globals in a block file?

Code:
$content = '';

$foo = 1;
function wtf() {
   global $foo;
   $bar = $foo;
   return $bar;
}
$content .= wtf();

_________________
Github: RavenNuke 
View user's profile Send private message
jestrella
Moderator



Joined: Dec 01, 2005
Posts: 593
Location: Santiago, Dominican Republic

PostPosted: Thu May 02, 2013 8:33 am Reply with quote

Try $GLOBALS['foo'] instead.

_________________
"For those whom have not reach the sky... Every mountain seems high"

Best Regards
Jonathan Estrella [ Only registered users can see links on this board! Get registered or login! ] 
View user's profile Send private message Visit poster's website
neralex







PostPosted: Thu May 02, 2013 8:59 am Reply with quote

I have it tried but i have in my called function a 2nd function in use. There i have the same problem, because the both functions are using the same module globals and if I pass the globals directly in the function then I have to change the entire module. Otherwise i must duplicate both functions in the block file but that is what i wanted to avoid.
 
spasticdonkey
RavenNuke(tm) Development Team



Joined: Dec 02, 2006
Posts: 1693
Location: Texas, USA

PostPosted: Thu May 02, 2013 11:03 am Reply with quote

try

$content = '';
global $foo;
$foo = 1;
function wtf() {
global $foo;
$bar = $foo;
return $bar;
}
$content .= wtf();
 
View user's profile Send private message Visit poster's website
neralex







PostPosted: Thu May 02, 2013 11:41 am Reply with quote

It works. Thank you! Smile
 
Display posts from previous:       
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> RavenNuke(tm) v2.5x

View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2007 phpBB Group
All times are GMT - 6 Hours
 
Forums ©