In today’s tutorial, we will learn about numbers in PHP. Numbers have numerous use in many programming languages. We use numbers in PHP too. There are two types of numbers used in PHP.

**1. Integers**

**2. Floats**

PHP for beginners part 8, string functions in PHP

Integer includes all positive and negative numbers. Floats contain numbers that include decimal points.

In this part, we will discuss the integers. The integer numbers can perform different functionalities within a program. Some of the main uses are performing the mathematical operation like Division, Multiplication, Addition, Subtraction etc.

Below is a simple program in which we will learn how can we use numbers within PHP.

<?php

$a = 5;

$b= 6;

$c= $a + $b;

echo $c;

?>

The program will output the addition of 5 and 6 that is 11. All we do is just simply store the values of 5 and 6 in variables a and b. In PHP we declare a variable by putting the $ sign at the start. After declaring a and b as variables we declare another variable c and store the value of variable a, and b in this third variable. Now we can call the variable c to output the addition.

Below is another example that will further elaborate the use of numbers in PHP.

<?php

$a = 5;

$b= 6;

echo “Result:”. ((( 2 + 3 + $a)* $b)/2 – 2);

?>

The program will output 28.

First of all, PHP will solve the numbers by using basic mathematical rule, i.e. start solving the numbers nested within braces.

PHP also provides the different built-in function to perform different functionalities within PHP by using numbers. Below is the list of functions that are used to perform different functionalities within PHP program.

**abs(0-300)**

This function is used to calculate the absolute value.

**pow(2,6)**

It is also called exponential function. This function is used to calculate the exponent of any number. It takes two arguments, first argument is the number whose power we want to raise. For example in example of two power 6, we are raising the power of 2 i.e. two will be the first argument. And six will be the second argument i.e. it will be the power of 2. The output of the above function will be 64.

**rand()**

To calculate any random number. The output can be any number.

**rand(5,20)**

This function is used to calculate random numbers between 5 and 20. The output can be any number between 5 and 20.

Note that in above function we didn’t specify any argument to the function so it will take any random number. But in second one we specify two argument to function 5 and 20. Which will restrict the function between 5 and 20.

**sqrt(25)**

To calculate square root of a number. The output will be 5, as 5 is the square root of 25.

**fmod(20,7)**

This function provide us the reminder. For example if we divide the 20 by 7 the remainder will be 6. This function will output the number 6.

Let me tell you here that 1 and “1” are not same. There is a lot of different between these two. 1 represent number and “1” represent string values. But PHP can convert the string into integers. After converting the string into integer PHP can also perform different mathematical functionalities on both values.

<?php

echo (1 + “2”);

echo (1 + “2 hours”);

//output will be 3 in both cases as PHP convert string into integer when perform mathematical functionality of integer with string.

?>

You can find more information about integers in php by clicking** here**.

KoreyHuggins says

I see your site needs some unique content. Writing manually is time consuming, but there is solution for

this. Just search for: Masquro’s strategies

Noor says

Great. I’ll try it

Quotes Tadka says

You don’t have a donate button! I’d certainly donate

to this fantastic blog! I suppose for now i’ll settle for book-marking and adding

your RSS feed to my Google account. I look forward to brand new updates

and will talk about this site with my Facebook group. Talk

soon!

Noor says

Great

nice to have you here on my blog.

you can also contact us using our contact us button.

gate 2017 mechanical results says

What’s up to every one, since I am in fact keen of reading this blog’s post to be updated daily.

It carries pleasant data.

Noor says

Thank you

gmail login says

I relish, lead to I discovered just what I was having a look for.

You have ended my four day lengthy hunt! God Bless you man. Have a nice

day. Bye

Noor says

Thanks for your kind words 🙂

keep visiting my blog.

seo says

Hello Web Admin, I noticed that your On-Page SEO is is missing a few factors, for one you do not use all three H tags in your post, also I notice that you are not using bold or italics properly in your SEO optimization. On-Page SEO means more now than ever since the new Google update: Panda. No longer are backlinks and simply pinging or sending out a RSS feed the key to getting Google PageRank or Alexa Rankings, You now NEED On-Page SEO. So what is good On-Page SEO?First your keyword must appear in the title.Then it must appear in the URL.You have to optimize your keyword and make sure that it has a nice keyword density of 3-5% in your article with relevant LSI (Latent Semantic Indexing). Then you should spread all H1,H2,H3 tags in your article.Your Keyword should appear in your first paragraph and in the last sentence of the page. You should have relevant usage of Bold and italics of your keyword.There should be one internal link to a page on your blog and you should have one image with an alt tag that has your keyword….wait there’s even more Now what if i told you there was a simple WordPress plugin that does all the On-Page SEO, and automatically for you? That’s right AUTOMATICALLY, just watch this 4minute video for more information at. Seo Plugin