⊗ppPmSFIB 289 of 447 menu

Conditions and Breaking PHP Code

Let's say we have some variable:

<?php $test = true; ?>

Let's output some piece of HTML code if our variable is equal to true:

<?php if ($test) { echo '<p>text</p>'; } ?>

We can rewrite this code to the following, with a break in PHP brackets:

<?php if ($test) { ?> <p>text</p> <?php } ?>

This can be simplified even more by using the alternative if syntax:

<?php if ($test): ?> <p>text</p> <?php endif; ?>

Given a variable:

<?php $show = true; ?>

Given the code:

<div> <p>text1</p> <p>text2</p> <p>text3</p> </div>

Output the provided HTML code if the variable show is equal to true.

English
AfrikaansAzərbaycanБългарскиবাংলাБеларускаяČeštinaDanskDeutschΕλληνικάEspañolEestiSuomiFrançaisहिन्दीMagyarՀայերենIndonesiaItaliano日本語ქართულიҚазақ한국어КыргызчаLietuviųLatviešuМакедонскиMelayuမြန်မာNederlandsNorskPolskiPortuguêsRomânăРусскийසිංහලSlovenčinaSlovenščinaShqipСрпскиSrpskiSvenskaKiswahiliТоҷикӣไทยTürkmenTürkçeЎзбекOʻzbekTiếng Việt
We use cookies for website operation, analytics, and personalization. Data processing is carried out in accordance with the Privacy Policy.
accept all customize decline