M Kingston

Something to be more generally aware of, of which this is a symptom, is that unlike C/C++ etc, PHP conditional statements do not define a scope at all (only functions have their own scope in PHP).

if (true) {
	$declared_in_if = "Hello world";
}
echo $declared_in_if; // outputs "Hello world"

In C a variable declared in the control statement conditional itself remains in scope for all subsequent blocks of the same control statement (i.e. all subsequent elses of an if)... whereas in PHP not even variables inside the blocks will go out of scope :D

Thu, 07/01/2016 - 16:31 Permalink

Restricted HTML

  • Allowed HTML tags: <a href hreflang> <em> <strong> <cite> <blockquote cite> <code> <ul type> <ol start type> <p> <br> <li> <dl> <dt> <dd> <h2 id> <h3 id> <h4 id> <h5 id> <h6 id>
  • Web page addresses and email addresses turn into links automatically.
  • Lines and paragraphs break automatically.
CAPTCHA