ADIP Chapter 1
ADIP Chapter 1
<?php <?php
echo “Welcome to Today’s tutorial!";
?>
</body>
Welcome to Today’s tutorial!
</html>
<?php
// This won't work because of the quotes around left!
echo "<h5 id=“left">I love using PHP!</h5>";
// OK because we escaped the quotes!
echo "<h5 class=\“left\">I love using PHP!</h5>";
// OK because we used an apostrophe '
echo "<h5 class=‘left'>I love using PHP!</h5>";
?>
Php Variables
A variable is a means of storing a value, such as text string “Second
year!" or the integer value 2. A variable can then be reused
throughout your code <?php
$my_string = “Welcome to today’s
Declaration syntax tutorial!";
$my_number = 2;
$variable_name = Value; $my_letter = s;
echo $my_string;
echo $my_number;
Echoing Variables echo $my_letter . “second year IT
student”;
Echoing Variables and Text Strings echo ” second year IT student” .
Using string concatenation operator (.)
$my_letter;
?>
PHP – Operators
while($x <= 5) {
while (condition is true) { echo "The number is: $x <br>";
$x++;
code to be executed; }
} ?>
<?php
$x = 1;
do {
code to be executed; do {
echo "The number is: $x <br>";
} while (condition is true); $x++;
} while ($x <= 5);
?>
<?php
for (init counter; test counter; increment counter) {
for ($x = 0; $x <= 10; $x++) {
code to be executed; echo "The number is: $x <br>";
} }
?>
More examples on PHP
……..Practice!!
Thank You ...
27