Welcome Guest, Not a member yet? Register   Sign In
global in helper-functions
#1

[eluser]Unknown[/eluser]
Hi,

i'm just trying to write my own helper, but somehow the global-keyword doesn't seem to work in my helper-files?

A short example of my helper-file:
Code:
<?php
$test = 'This is a test';

function test() {
  global $test;
  var_dump($test);
}

var_dump($test);
test();
?>

The first var_dump works as expected, the value of $test is shown... But the second one, the one inside the function just outputs NULL... global doesn't seem to work, but there isn't a parse_error or any kind of php-message...

If i try the same code outside of code-igniter and load the file directly everythings works as it should...

Where is my thinking-error? Wink


Messages In This Thread
global in helper-functions - by El Forum - 06-29-2009, 12:07 PM
global in helper-functions - by El Forum - 06-29-2009, 12:16 PM
global in helper-functions - by El Forum - 06-29-2009, 12:24 PM
global in helper-functions - by El Forum - 06-29-2009, 01:45 PM
global in helper-functions - by El Forum - 09-08-2009, 11:46 PM
global in helper-functions - by El Forum - 09-09-2009, 01:42 AM
global in helper-functions - by El Forum - 09-23-2009, 02:26 AM



Theme © iAndrew 2016 - Forum software by © MyBB