Monday, April 28, 2014

PHP Tutorial Seven : Indentation of PHP Code


Last tutorial we know "How to  Create index.php File and Write PHP Code ".  This tutorial we will  know what is indentation and how to use it in php code. We see this code :


---------------------------------------------------
<?php
$name = 'Saud';
$age =  25;
if (strtolower($name)=='saud') {
if ($age>=25) {
if (1==1) {
echo 'Yes, 1 is equal to 1!';
}
}
} else {
echo 'You\'re not Saud!';
}
?>
---------------------------------------------------

Now we again see this code :

---------------------------------------------------
<?php
$name = 'Saud';
$age =  25;

if (strtolower($name)=='saud') {
    if ($age>=25) {
        if (1==1) {
            echo 'Yes, 1 is equal to 1!';
        }
    }
} else {
    echo 'You\'re not Saud!';
}
?>
---------------------------------------------------

In fist cod we see all line is left align. Second code few line is left align and few line is some space in left. Some code indent same align need for code understanding.

No comments :

Post a Comment