IT SOLUTIONS
Your full service technology partner! 
-Collapse +Expand
To/From Code
-Collapse +Expand Members-Only
Sign in to see member-only pages.
   ► KBTo/From GuidesPerl  Print This     

Unary Operators (Perl and PHP Cross Reference Guide)

By Mike Prestwood

Perl versus PHP: A side by side comparison between Perl and PHP.

 
Operators
 

A language symbol used for assignment, comparison, computational, or as a logical.

Unary Operators

[Other Languages] 

General Info: Unary Operator

An operation with only one operand (a single input). Common unary operators include + plus, - minus, and bitwise not. Some operators can function as both unary and binary operators. For example, + and - operators can serve as either.

Languages Focus

What unary operators are supported in additoin to the standard plus, minus, and bitwise not.

Perl: 

An operation with only one operand (a single input). The following are the Perl unary operators: !, -, ~, +, \, &, and *.

  • ! performs logical negation which is "not"
  • - performs arithmetic negation if the operand is numeric.
  • ~ performs bitwise negation, that is 1's complement.
  • + has no semantic effect whatsoever, even on strings.
  • \ creates a reference to whatsoever follows.
  • & Address of operator.
  • * Dereference address operator.
PHP: 

A unary operator operates on only one value.

PHP Examples:

  • ! negation operator
  • ++ increment operator
  • -- decrement operator












Sales Website: www.prestwood.com Or visit our legacy sales site: 
legacy.prestwood.com


©1995-2024 Prestwood IT Solutions.   [Security & Privacy]