Jump to content

Rek

Members
  • Posts

    1
  • Joined

  • Last visited

Everything posted by Rek

  1. Rek

    PHP question

    Hi, I am completely a new to PHP. I am just in beginner level. So when i was going through the concept of Keywords global,local and static. there was an example specified to make us understand for static key word. "sometimes we want a local variable NOT to be deleted. We need it for a further job" which means the value when defined as static will no change right! below is the example i have seen . Code: <?phpfunction myTest() { static $x = 0; echo $x; $x++;}myTest();myTest();myTest();?> Result: 0 1 2 my question is how is x getting incremented if it is defined as static. can some one explain me. again if i am wrong please correct me as i really dont know any in PHP. I am beginer. Thank you! Rekha
×
×
  • Create New...