PHP kody we ýagdaýy
Bizde bir üýtgeýän bolsun:
html<?php
$test = true;
?>
Üýtgeýjämiz true deň bolsa, birneme HTML
koduny görkezeliň:
html<?php
if ($test) {
echo '<p>text</p>';
}
?>
Bu kody PHP böwünleriniň ýarylmagy bilen aşakdaky görnüşe öwürmek bolar:
html<?php if ($test) { ?>
<p>text</p>
<?php } ?>
Bu if ýönekeýleşdirilen sintaksisi bilen has
ýönekeýleşdirip bolýar:
html<?php if ($test): ?>
<p>text</p>
<?php endif; ?>
Задание 1
Üýtgeýän berlen:
html<?php
$show = true;
?>
Kod berlen:
html<div>
<p>text1</p>
<p>text2</p>
<p>text3</p>
</div>
show üýtgeýjämiz true deň bolsa,
görkezilen HTML kody görkeziň.