05.05.2013 Views

Programming PHP

Programming PHP

Programming PHP

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

first time the function is called. To declare a function variable static, use the static<br />

keyword at the variable’s first use. Typically, the first use of a static variable is to<br />

assign an initial value:<br />

static var [= value][, ... ];<br />

In Example 3-4, the variable $count is incremented by one each time the function is<br />

called.<br />

Example 3-4. Static variable counter<br />

function counter( ) {<br />

static $count = 0;<br />

return $count++;<br />

}<br />

for ($i = 1; $i

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!