Summary


PHP allows you to take control of your code with operators and flow control. Operators give you a quick way to handle data in single statements, adding numbers, for example, or testing equality. Flow control statements are very powerful because they let you make decisions based on the data in your scripts. Here's a summary of the salient points:

  • The five math operators, +, -, *, /, and %, give you basic math capabilities. The math functions, from abs to tanh, give you more math power.

  • The assignment operators, =, +=, -=, *=, /=, .=, %=, &=, |=, ^=, <<=, and >>=, let you assign values to variables, even combining the assignment with other operators such as +, -, *, and so on.

  • The ++ and -- operators let you increment and decrement values.

  • The execution operator, ``, lets you execute system commands.

  • The string operators, . and .=, let you concatenate strings.

  • The bitwise operators, &, |, ^, ~, <<, and >>, let you work on the individual bits in values.

  • The comparison operators, ==, ===, !=, <>, !==, <, >, <=, and >=, let you compare values.

  • The logical operators, and, or, xor, !, &&, and ||, let you chain truth values together.

  • The if statement lets you check the truth value of expressions and execute code depending on the results.

  • The switch statement lets you test many conditions at once, sort of like an extended if statement.

  • The for loop iterates over statements as needed while a test condition remains true. It has an initialization part, a part tested after every loop iteration, and a part that is executed after every loop iteration.

  • The while loop keeps looping over a set of statements while a test condition remains true.

  • Do…while loops are the same as while loops, except that the test condition is tested at the end of the loop.

  • The foreach loop is designed to work with collections of data such as arrays.



    Spring Into PHP 5
    Spring Into PHP 5
    ISBN: 0131498622
    EAN: 2147483647
    Year: 2006
    Pages: 254

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net