Thread: TStaticVar()
View Single Post
  #2  
Old 03-19-2015, 10:58 AM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 5,200
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
It's useful for when you want to create an object to pass to another function or script. It also provides a clean object slate that doesn't have all the predefined Graal variables.

PHP Code:
function onCreated() {
  
temp.noobj.3;
  
temp.noobj.5;
  
  echo(
temp.noobj.x SPC temp.noobj.y);
  
test(temp.noobj);

  
temp.obj = new TStaticVar();
  
temp.obj.3;
  
temp.obj.5;

  
test(temp.obj);

  
// make sure you destroy them when you're done with them 
  // as they aren't always garbage collected properly...
  
temp.obj.destroy();
}

function 
test(obj) {
  if (
obj.|| obj.y) {
    echo(
obj.x SPC obj.y);
  } else {
    echo(
"no x or y detected");
  }

echos

3 5
no x or y detected
3 5
__________________
Quote:
Reply With Quote