Search code examples
phpoperator-precedence

PHP Order of operations


I wanted to know how PHP would execute this. Order of operations

addslashes(strip_tags($record['value']));

Is addslashes called first or strip_tags?

In other words, does it execute from the inside out or from the outside in?


Solution

  • From the inside out.

    The things passed into a function in PHP are called "expressions". When you pass an expression as a parameter, what you're really passing is the value of that expression. In order to do that, the expression is evaluated before it is passed in.

    More about expressions from the php manual.