Create $var with some function



Hi there,

Someone know if can (if possible, how) i create a $var on my script like this:

function createvar($var) {
$var = 'foo';
global $var;
//or global $$var, i don't know it yet.
}

so i'd call,

createvar('myvar');

so i'd could call $myvar, like this:

echo $myvar; // prints 'foo'

is it possible?



.



Relevant Pages

  • Re: Request.QueryString
    ... var a = request.querystring; ... Response.write('serverside myVar contains: ' + myVar); ... The first round ofcourse it will show "undefined", ...
    (comp.lang.javascript)
  • Re: Delphi popularity on the rise
    ... var myVar:= TMyObject.Create; ... type inferrence makes hardly any sense without inline declaration ... I'm of two minds about the inline declaration of variables. ...
    (borland.public.delphi.non-technical)
  • /bin/sh passing arguments to sourced script
    ... I am trying to execute a bourne shell script that calls ... echo "VAR from 2.sh: $VAR" ... ARGS: foo ... ARGS: bar ...
    (comp.unix.shell)
  • Re: Why do directly imported variables behave differently than those attached to imported module?
    ... global var ... Script using this module: ... from foo import * ... Plain `var` is in your script's namespace so you could access it as ...
    (comp.lang.python)
  • Re: variable scope
    ... Where is myVar defined within the changeMyVar() function? ... If you want/need a local myVar that masks the already defined global myVar ... then you have to explicitly define it locally with var. ...
    (microsoft.public.scripting.jscript)