How to use an Operators in PHP?
Hello friends,
I am new to the PHP programming language. I have used an operators in different programming language but now I want to use it in PHP. Since, I don't know anything about the PHP, I am not even tried using it. So thought to post here, since you guys explain very clearly. Please tell me how to use an Operators in PHP?
Re: How to use an Operators in PHP?
There are three types of operators. First, the unary operator which operates on a single value, for example! (the negation operator) or + + (the increment). The second group are termed binary operators; and The third group is the ternary operator:?:. They must be used to select between two expressions depending on a third, rather than to select two sentences or paths of execution. Surrounding ternary expressions with parentheses are a very good idea.
Re: How to use an Operators in PHP?
The following are the Operator Precedence :
- new clone
- + + --
- ~ - (Int) (float) (string) (array) (object) (bool) @
- !
- * /%
- + -.
- <<>>
- <<=>> = <>
- ==! = ===! ==
- = + = -= *= / = .=% = & = | = ^ = <<=>> =
- & &
Re: How to use an Operators in PHP?
You should also know about the Assignment Operators, since they are very commonly used in operators. The assignment operator is the simplest sign "=". The first instinct is to think that this sign means "equal to". This is not the case. It means that the left operand gets set to the value of the expression is the right of the equals sign. The value of an assignment expression is the value assigned. In addition to the basic assignment operator, there are "combined operators" for all operators arithmetic, array union and operators on strings. This allows to use the value of a variable in an expression and affect the outcome of this expression to that variable.
Re: How to use an Operators in PHP?
Comparison operators, as their name implies, allow you to compare two values. You should also be interested in the comparison tables of types, because they show examples of many types of comparisons :
- Equal - TRUE if $a is equal to $b.
- Identical - TRUE if $a is equal to $b, and they are of the same type.
- Not equal - TRUE if $a is not equal to $b.
- Less than - TRUE if $a is strictly less than $b.
- Greater than - TRUE if $a is strictly greater than $b.
- Less than or equal to - TRUE if $a is less than or equal to $b.
- Greater than or equal to - TRUE if $a is greater than or equal to $b.
Re: How to use an Operators in PHP?
PHP supports a control operator error: @ it. When this operator is prepended to an expression PHP error messages that may be generated by that expression will be ignored. If the option track_errors is enabled, error messages generated by the expression will be saved in the global variable $ php_errormsg. This variable will be overwritten on each error. It must then be monitored often to use it. The @-operator works only on expressions. The rule of thumb is: if you can take the value of something, you can prepend the @.