Some elements are essential for developing any type of application, among these elements mathematical operators and functions related to string some of these elements are essential, without them it would be impossible to perform any kind of processing. Therefore it is important to understand how they are declared and how they are worked in programming.
In PHP the arithmetic operators are worked very simply, using the signals already known patterns is easier assimilates them and implement them accordingly.
Check out the examples below to arithmetic operators in PHP:
$var = 2 +2 / / Addition
$var = 2-2 / / Subtraction
$var = 2/2 / / Division
$var = 2 * 2 / / Multiplication
The variable $var assumed the operation result according to the calculation.
You can also use the calculations with variables that take a value at the beginning of the implementation, as shown below:
$var2 = 2;
$var = $var2 +2 / / Addition
$var = $var2 -2 / / Subtraction
$var = $var2 / 2 / / Division
$var = $var2 * 2 / / Multiplication
Another element widely used in PHP are the strings, this type of data is represented by any textual content.
$var = “Text 1”;
$var2 = “text 2”;
One of the most common operators in string is the concatenation, it is possible to join two strings in the same variable, as in the example below:
$var = “Text 1”;
$var2 = “text 2”;
$var3 = $ var. “”. $var2;
The variable $var3 assumed then the value “Text1 Text2”.
These basic operators are part of everyday life for all programmers who work with the PHP language and more than that, are essential in any type of activity.
If you are taking your first steps in the development of PHP applications count on one of the development tools that are market benchmark, Scriptcase. Go to the download page, download the free version now and start right now to enjoy all the benefits that only Scriptcase offers.
Comment this post