programming languages tutorials

programming languages tutorials


String Operators in php

Posted: 19 Dec 2012 09:02 AM PST


 String Operators
As we have already seen in the Echo Lesson, the period "." is used to add two strings together, or more
technically, the period is the concatenation operator for strings. 


PHP Code:


$a_string = "Hello";
$another_string = " Billy";
$new_string = $a_string . $another_string;
echo $new_string . "!";

Display:


Hello Billy!  

Comparison Operators in php

Posted: 19 Dec 2012 08:58 AM PST


Comparison Operators
Comparisons are used to check the relationship between variables and/or values. If you would like to see
a simple example of a comparison operator in action, check out our If Statement Lesson. Comparison operators are used inside conditional statements and evaluate to either true or false. Here are the most important comparison operators of PHP. 

Assume: $x = 4 and $y = 5; 


Operator English ExampleResult
== Equal To $x == $y false
!= Not Equal To $x != $y true
< Less Than $x < $y true
>Greater Than $x > $y false
<= Less Than and Equal To $x <= $y true
>= Greater Than and Equal To $x >= $y false


Assignment Operators in php

Posted: 19 Dec 2012 08:45 AM PST


Assignment Operators
Assignment operators are used to set a variable equal to a value or set a variable to another variable's
value. Such an assignment of value is done with the "=", or equal character.

Example

•  $my_var = 4; 
•  $another_var = $my_var  

Now both $my_var and $another_var contain the value 4. Assignments can also be used in conjunction
with arithmetic operators.
  

Php operator

Posted: 19 Dec 2012 09:06 AM PST

Operators

In all programming languages, operators are used to manipulate or perform operations on variables and
values. You have already seen the string concatenation operator "." in the Echo Lesson and the assignment
operator "=" in pretty much every PHP example so far.
  There are many operators used in PHP, so we have separated them into the following categories to make
it easier to learn them all.


 • Assignment Operators
 • Arithmetic Operators
 • String Operators



Post a Comment