News Feed
Sections




News Archive
Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Nikita Popov:
Order of evaluation in PHP
September 25, 2013 @ 10:51:35

If you're the kind of person that wonders more about the internals of PHP and how it works "under the covers" you'll find this new post from Nikita Popov a good read. It talks about how PHP handles its order of operations in more complex evaluation statements.

At this point many people seem to think that the order in which an expression is evaluated is determined by operator precedence and associativity. But that's not true. Precedence and associativity only tell you how the expressions are grouped.[...] What does this tell us about the order of evaluation? Nothing. Operator precedence and associativity specify grouping, but they do not specify in which order the groups are executed.

He gives a few examples to illustrate his point including multiple increments of the same variable at one time and how it's the "fault" of the compiled variables that were introduced in PHP 5.1. He shows the opcode version of the same PHP userland code and talks briefly about how to avoid this odd functionality in your application.

0 comments voice your opinion now!
order evaluation opcode compiled variable

Link: https://gist.github.com/nikic/6699370

blog comments powered by Disqus

Similar Posts

Alex Netkachov's Blog: 6 PHP coding tips to write less code

Derick Rethans' Blog: Debugging Variables

Lukas Smith's Blog: Opcode Best Practices (webcast)

Federico Cargnelutti's Blog: An Alternative to Zend_Controller: The Router

Kore Nordmann's Blog: Installing cairo_wrapper on Gentoo


Community Events





Don't see your event here?
Let us know!


series framework list laravel wordpress library introduction configure code interview language podcast release unittest threedevsandamaybe api community developer application install

All content copyright, 2014 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework