can any1 plz help me write this code...

i want to print the valu of variable z.
there are three variables x, y and z

x is initialized some where else...
y=x z=z+y

first call of function x=10 y=10 z=10
second call x=20 y =20 z=20+10
third call x=30 y= 30 z=30+30
fourth call x=40 y=40 z=90+40

and so on

Try this:

function doOperation()
{
  static $x=0;
  static $y=0;
  static $z=0;
  $y=$x;
  $z=$z+$y;
  echo "X: ".$x."<br>";
  echo "Y: ".$y."<br>";
  echo "Z: ".$z."<br>";
  echo "------<br>";
  $x=$x+10;
}
doOperation();
doOperation();
doOperation();
doOperation();
doOperation();
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.