On Tue, March 4, 2008 6:16 am, Svevo Romano wrote:
> Hello,
>
> I got this e-mail address from the ŒAdd note¹ page within the php.net
> website. I was going to post something that was a question and I
> realised I
> was in the wrong place :)
>
> I have 2 basic questions and I¹m sorry if they may seem too basic. I¹m
> a bit
> new to php.
>
> The first question has to do with the static variables. I understand
> how
> this works from the examples, but there is something that I cannot
> seem to
> find clearly stated anywhere on that page.
>
> The example:
>
> <?php
> function Test()
> {
>     static $a = 0;
>     echo $a;
>     $a++;
> }
> ?>
>
> Of course works (I¹ve tested it on my server), but it is still obscure
> to
> me, according to general programming principles, since I¹m still
> assigning
> zero (0) to $a on each call to the Test function. How does this
> exactly work
> when the static word is found? Is there and index that keeps track of
> each
> call to the function ignoring any assignment in subsequent calls to
> the
> function? Why doens¹t this work when you assign an expression result
> to the
> variable?

It's not an assignment, it's an initialization, and, yes, the compiler
does "keep track" and doesn't do that after the first time.

*THIS* would be what you describe:
function Test(){
  static $a;
  $a = 0;
  echo $a;
  $a++;
}

> The second question has to do with the online manual. I¹ve found
> several
> things on that manual specified in comments and not in the actual
> manual
> part of it. What is the nature of the manual? Contributions from
> voluteers?

The manual is contributions from volunteers who have been "blessed" by
the other volunteers (viz) to edit the manual.

The "Notes" is from anybody on the planet with a web browser that can
beat the CAPTCHA.

> Is there any official manual I can buy that documents everything about
> the
> language from the source? Or any official company that maintains the
> language and that possibly offers support as well?

There is nothing you can buy that's more official (nor more complete)
than the on-line manual.

You can buy support from Zend, which is a separate company run by two
guys who happen to be core developers;  You can probably buy support
elsewhere as well.

PS
If you can find a language with a better manual, I'd like to see it...
:-)

-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/from/lynch
Yeah, I get a buck. So?


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to