<p>I have a variable that is built in loop. Something like:</p>

<pre><code>$str = "";
for($i = 0; $i &lt; 10; $i++) $str .= "something";
</code></pre>

<p>If $str = "" is ommitted, I get undefined variable notice, but I thought php auto-declare a variable the first time it sees undeclared one?</p>

<p>How do I do this right?</p>

You get the undefined variable because you're concatenating the value of itself with another value.
The equivalent of
```
$str = $str . "something";
```
So, it can't say what's the initial value is. It's the equivalent of this:
```
$str = [undefined value] . "something";
```
What's the result of a concatenation of
```
[undefined value]
```
and
```
"something"
```
? The interpreter can't say...
So, you have to put
```
""
```
in the variable first to initiate the variable's value, as you did.
HTH