Search notes:

PowerShell: logical operators

The logical operators in PowerShell are: -and, -or, -xor, -not and !.
The exclamation mark is equivalent to -not.
A logical operator evaluates to a boolean data type.

Short-circuiting

The logical operators perform short-circuit evaluation, that is, only parts of an expression with logical operators are evaluated that are needed to determine the result.
For example, if the left argument to -or is $true, the right argument does not need to be looked at because the entire expression is $true anyway.
In the following example, the write-host cmdlet is not invoked:
PS C:\> $true -or (write-host 'Evaluated')
However, here it is:
PS C:\> $false -or (write-host 'Evaluated')

See also

The if statement
operators

Index

Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 8 attempt to write a readonly database in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php:78 Stack trace: #0 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(78): PDOStatement->execute(Array) #1 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(30): insert_webrequest_('/notes/Windows/...', 1758207329, '216.73.216.150', 'Mozilla/5.0 App...', NULL) #2 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/Windows/PowerShell/language/operator/logical(61): insert_webrequest() #3 {main} thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 78