PHP TUTORIALS
29 Jan 2014
OPERATORS IN PHP :- Logical Operators
Logical operators are used when we want to combine operations and
expressions into a set of logical comparisons. They are usually used in
conjuction with "if and "else" statements to lay out the dynamic logic
we need in many situations as we advance in our PHP development.
example:-
Name | Usage | Result |
And | $var1 && $var2 | TRUE if both $var1 and $var2 are TRUE |
And | $var1 and $var2 | TRUE if both $var1 and $var2 are TRUE |
Or | $var1 or $var2 | TRUE if either $var1 or $var2 is TRUE |
Or | $var1 || $var2 | TRUE if either $var1 or $var2 is TRUE |
Xor | $var1 xor $var2 | TRUE if either $var1 or $var2 is TRUE, but not both |
Is Not | !$var1 | TRUE if $var1 is not TRUE |
example:-
28 Jan 2014
OPERATORS IN PHP :- Comparison Operators
PHP comparison operators allow you to compare two values against each
other.The comparison is read from left to right by the PHP engine. Widely use in Conditional Logic and Control Structures.
- Equal :- $var1 == $var2 Result :- TRUE if $var1 is equal to $var2.
- Identical :- $var1 === $var2 Result :- TRUE if $var1 is equal to $var2, and they are of the same type
- Not Equal :- $var1 != $var2 Result :- TRUE if $var1 is not equal to $var2
- Not Equal :- $var1 < > $var2 Result :- TRUE if $var1 is not equal to $var2.
- Not Identical :- $var1 !== $var2 Result :- TRUE if $var1 is not equal to $var2, or they are not the same type.
- Less Than :- $var1 < $var2 Result :- TRUE if $var1 is strictly less than $var2.
- Greater Than :- $var1 > $var2 Result :- TRUE if $var1 is strictly greater than $var2.
- Less Than or Equal to :- $var1 <= $var2 Result :- TRUE if $var1 is less than or equal to $var2.
- Greater Than or Equal to :- $var1 >= $var2 Result :- TRUE if $var1 is greater than or equal to $var2.
OPERATORS IN PHP :- Concatenation
The concatenation operator ( . ) returns
the combined value of its right and left values.
The variable's data type has an affect on the output.
example :-
The concatenating assignment operator ( .= ), which appends the variable value on the right side to the variable on the left side. We use this method many times to compound and keep adding to one variable so it will retain its current value, and just append the new values onto the current value's tail end.
example :-
The variable's data type has an affect on the output.
example :-
The concatenating assignment operator ( .= ), which appends the variable value on the right side to the variable on the left side. We use this method many times to compound and keep adding to one variable so it will retain its current value, and just append the new values onto the current value's tail end.
example :-
OPERATORS IN PHP :- Increment and Decrement operator
Incrementing and Decrementing operators are very widely used in most programming languages. They allow a PHP programmer to increment and decrement values as needed.
- Pre-Increment ++$MyVariable Result Increments $MyVariable by one.
- Post-Increment $MyVariable++ Result Returns $MyVariable, then increments $myVar by one.
- Pre-Decrement --$MyVariable Result Decrements $MyVariable by one.
- Post-Decrement $MyVariable-- Result Returns $MyVariable, then decrements $myVar by one.
20 Apr 2013
What is Variable in php ?
Variables are used to make processes we script out more dynamic. In the
programming world the word variable means
"a symbolic name associated with a value and whose associated value may be changed".
PHP sports a cool feature called automatic data typing. A PHP developer can claim variables and use them in most common situations without having to claim the data type that the variable is.
How to create variable
Predefined Variables
There are a set of predefined variables in PHP that are always available for use in any script or scope in your applications. When data is created, sent, or stored using mechanisms that create superglobal variables, we can then access those variables site-wide or all throughout our scripts and scope. Predefined superglobals are available to all of your scripts that are part of a website or application you are creating.
The superglobal variables are:
example
Magic Constants (Predefined)
"a symbolic name associated with a value and whose associated value may be changed".
PHP sports a cool feature called automatic data typing. A PHP developer can claim variables and use them in most common situations without having to claim the data type that the variable is.
How to create variable
- PHP variables must made by placing a dollar sign [ $ ] and then the name of the variable directly after it.
- Variable name must starts from character or underscore.
- Do not use a NUMBER to start a variable name.
Predefined Variables
There are a set of predefined variables in PHP that are always available for use in any script or scope in your applications. When data is created, sent, or stored using mechanisms that create superglobal variables, we can then access those variables site-wide or all throughout our scripts and scope. Predefined superglobals are available to all of your scripts that are part of a website or application you are creating.
The superglobal variables are:
$_GET | Stores any variables created using the GET method |
$_POST | Stores any variables created using the POST method |
$_REQUEST | Stores any variables created through a user input script (it can access both POST or GET) |
$_FILES | Stores any file upload variables created through user input scripts |
$_SESSION | Stores any variables created through registering session variables |
$_COOKIE | Stores any variables created through setcookie |
$GLOBALS | Stores any variables that have been globally defined |
$_SERVER | Stores server information such as headers, file names, reference paths, and current page. |
$_ENV | Stores any variables associated with the server environment. |
example
Magic Constants (Predefined)
Subscribe to:
Posts (Atom)