RaduTodor / TestingPHP

A repository for teaching purposes.
0 stars 0 forks source link

Alt echo ce il puteti simplifica #3

Open sica07 opened 5 years ago

sica07 commented 5 years ago

Partea asta: https://github.com/RaduTodor/TestingPHP/blob/ff892669037ff36de21ab8cc38fa0e67f735b7bc/public/index.php#L23-L37 se poate scrie si ca:

<?php if(isset($_SESSION["username"])):?>

<label for="username">Username <?=$_SESSION["username"]?></label>
<label for="email">Email <?=$_SESSION["email"]?></label>
<label for="birth_date">Birth Date <?=$_SESSION["birth_date"]?></label>
<label for="first_name">First Name <?=$_SESSION["first_name"]?></label>
<label for="last_name">Last Name <?=$_SESSION["last_name"]?></label>
<label for="gender">Gender <?=$_SESSION["gender"]?></label>

<?php else:?>

<label for="notLogged">YOU ARE NOT LOGGED IN</label>

<?php endif?>

<?=$variabila?> este o prescurtare pentru <?php echo $variabila?> Orice bloc de genul if()else sau if()elseif()else sau foreach(), for() etc se poate introduce in html folosind tag-urile <?php ceva()?> si e obligatoriu sa se inchida acel bloc cu tag-ul: <?php endceva ?> De exemplu: <?php foreach($var as $key => $value):?> <?php endforeach?>