Php Code – Codemeets– 02
php code lesson 2. Today we going to learn more about php. In this tutorial, we will focus on HTML, Variable, Strings, Numbers, and Operations. It can provide extensive knowledge.
Use HTML For PHP
You can see below html tag use in your php file.
<?php echo "<h1>Micke</h1>"; echo "<hr>"; echo "<h1>Jhone</h1>" ?>
Variables are used to store information to be referenced and manipulated in a computer program. They also provide a way of labeling data with a descriptive name, so our programs can be understood more clearly by the reader and ourselves. It is helpful to think of variables as containers that hold information. Their sole purpose is to label and store data in memory. This data can then be used throughout your program.launchschool.com
Now you know what is variable, let’s use it php code.
<?php $charname ="Jhone"; $charage = '18'; echo "my name is = $charname";
echo "my age = $charage"; ?>
Working with Strings
string is traditionally a sequence of characters. now you can see how to work it. Look at Example.
<?php $pharase = "Hello World";
Working With Numbers
Every computer language uses numbers in particular. This is because it allows you to easily control the data. let show you how to work with numbers in php.
<?php echo 5; //5 echo 5 + 9; //14 ?>
<?php $num = 10; $num ++; echo $num; //11
In mathematics we use different operations i.e. maximum value, square root, fall. They are also used differently in programming. The following example will give you a broader understanding.
Special Example for Lesson 02
- First get square root in x.
- y is max round number.
- z is positive number.
- R is X+Z/Y.
- (X=144, Y=2.2, Z=-33)
- Find R?
<?php $x = 144; $y = 2.2; $z = -33; $x1 = sqrt($x); $y1 = ceil($y); $z1 = abs($z); $R1 = $x1 + $z1; $R = $R1 / $y1; echo "R"; ?> <?php $x = 144; $y = 2.2; $z = -33; $x1 = sqrt($x); $y1 = ceil($y); $z1 = abs($z); $R1 = $x1 + $z1; $R = $R1 / $y1; echo "R = "; echo $R; ?>
Thank for all!
More php ClickHere!
See you Next php Lesson Soon!