-
[PHP] 8. 연산자 (Operators) - PHP 강좌, PHP5Web/PHP 2015. 6. 13. 13:42
PHP 5 Operators
1. PHP Operators
연산자(Operator)는 변수와 값을 연산을 수행하기 위해 사용됩니다.
2. PHP Arithmetic Operators
PHP 산술(Arithmetic) 연산자는 숫자 값을 일반적인 산술 연산을 하기 위해 사용됩니다.
[ 출처: W3Schools ]Operator Name Example Result Show it + Addition $x + $y Sum of $x and $y Show it ≫ - Subtraction $x - $y Difference of $x and $y Show it ≫ * Multiplication $x * $y Product of $x and $y Show it ≫ / Division $x / $y Quotient of $x and $y Show it ≫ % Modulus $x % $y Remainder of $x divided by $y Show it ≫ ** Exponentiation $x ** $y Result of raising $x to the $y'th power (Introduced in PHP 5.6) 3. PHP Assignment Operators
PHP 할당 연산자는 숫자 값을 변수의 값으로 쓰기 위해 사용됩니다.
[ 출처: W3Schools ]Assignment Same as... Description Show it x = y x = y The left operand gets set to the value of the expression on the right Show it ≫ x += y x = x + y Addition Show it ≫ x -= y x = x - y Subtraction Show it ≫ x *= y x = x * y Multiplication Show it ≫ x /= y x = x / y Division Show it ≫ x %= y x = x % y Modulus Show it ≫ 4. PHP Comparison Operators
PHP 비교 연산자는 두 값을 비교하기 위해 사용됩니다(숫자 혹은 문자)
Operator Name Example Result Show it == Equal $x == $y Returns true if $x is equal to $y Show it ≫ === Identical $x === $y Returns true if $x is equal to $y, and they are of the same type Show it ≫ != Not equal $x != $y Returns true if $x is not equal to $y Show it ≫ <> Not equal $x <> $y Returns true if $x is not equal to $y Show it ≫ !== Not identical $x !== $y Returns true if $x is not equal to $y, or they are not of the same type Show it ≫ > Greater than $x > $y Returns true if $x is greater than $y Show it ≫ < Less than $x < $y Returns true if $x is less than $y Show it ≫ >= Greater than or equal to $x >= $y Returns true if $x is greater than or equal to $y Show it ≫ <= Less than or equal to $x <= $y Returns true if $x is less than or equal to $y Show it ≫ [ 출처: W3Schools ]5. PHP Increment / Decrement Operators
PHP 증가 연ㅅ
Operator Name Description Show it ++$x Pre-increment Increments $x by one, then returns $x Show it ≫ $x++ Post-increment Returns $x, then increments $x by one Show it ≫ --$x Pre-decrement Decrements $x by one, then returns $x Show it ≫ $x-- Post-decrement Returns $x, then decrements $x by one Show it ≫ [ 출처: W3Schools ]6. PHP Logical Operators
Operator Name Example Result Show it and And $x and $y True if both $x and $y are true Show it ≫ or Or $x or $y True if either $x or $y is true Show it ≫ xor Xor $x xor $y True if either $x or $y is true, but not both Show it ≫ && And $x && $y True if both $x and $y are true Show it ≫ || Or $x || $y True if either $x or $y is true Show it ≫ ! Not !$x True if $x is not true Show it ≫ [ 출처: W3Schools ]7. PHP String Operators
Operator Name Example Result Show it . Concatenation $txt1 . $txt2 Concatenation of $txt1 and $txt2 Show it ≫ .= Concatenation assignment $txt1 .= $txt2 Appends $txt2 to $txt1 Show it ≫ [ 출처: W3Schools ]8. PHP Array OperatorsOperator Name Example Result Show it + Union $x + $y Union of $x and $y Show it ≫ == Equality $x == $y Returns true if $x and $y have the same key/value pairs Show it ≫ === Identity $x === $y Returns true if $x and $y have the same key/value pairs in the same order and of the same types Show it ≫ != Inequality $x != $y Returns true if $x is not equal to $y Show it ≫ <> Inequality $x <> $y Returns true if $x is not equal to $y Show it ≫ !== Non-identity $x !== $y Returns true if $x is not identical to $y Show it ≫ [ 출처: W3Schools ]'Web > PHP' 카테고리의 다른 글
[PHP] 11. 반복문 (while loop) - PHP 강좌, PHP5 (0) 2015.06.13 [PHP] 10. 조건문 (switch) - PHP 강좌, PHP5 (0) 2015.06.13 [PHP] 9. 조건문 (if, else, elseif) - PHP 강좌, PHP5 (0) 2015.06.13 [PHP] 7. 상수 (Constants) - PHP 강좌, PHP5 (0) 2015.06.13 [PHP] 6. 문자열 (Strings) - PHP 강좌, PHP5 (0) 2015.06.13 [PHP] 5. 데이터 타입(Data types) - PHP 강좌, PHP5 (0) 2015.06.13