نجوم مصرية
منتديات نجوم مصرية منتدى المدونين واصحاب المواقع منتدى لغات البرمجة



تابع نجوم مصرية على أخبار جوجل




PHP Step by step - Addition in PHP

 

In the last lesson we learned how to define the variables and used it in our code.
PHP Step by step - Variables
OK now we will learn how to make some calculations in php

if we put the first var with the value 10 and the other with the value 20 and print the sum of them like
[PHP]<?php
$var1 = 10;
$var2 = 20;
$total = $var1 + $var2;
print( 'The two variables added together = ' . $total );
?>[/PHP]
Note:
in $total var we put the + between the two vars to calculate the two vars and in print function we put the text between ' ' or u can put them between " " and separate between the statement and the $total var by . and in line end put ;

Exercise
Add a third variable to your code. Assign a value of 30 to your new variable. Put the sum total of all three variables into the variable called $sum_total. Use concatenation to display the results. (In other words, add up 10, 20, and 30!)


You don't have to use variable names to add up. You can do this:

print (10 + 20 + 30);

Or even this:

$number = 10;

print ($number + 30);

But the point is the same - use the plus symbol (+) to add up.






المقال "PHP Step by step - Addition in PHP" نشر بواسطة: بتاريخ:



اسم العضو:
سؤال عشوائي يجب الاجابة عليه

الرسالة:


رابط دائم

مواضيع مشابهة:
PHP Step by step - Variables
president Mubarak step down now , details in video

Powered by vBulletin Version 3.8.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd
جميع الحقوق محفوظة © fmisr.com منتديات نجوم مصرية