[Solved] How to use the php if statement [closed]


You may do it this way using open/close bracket {}

<?php 
if ( 1==2) { 
?>
<textarea>
"Add multiple lines of text here and watch the scrollbars grow.">
</textarea>
<?php } ?>

In general rules you need to enclose all the if else statement using php tag and the html outside it. You may also use echo.


<?php  if ( condition ) { ?>
 <!-- your html goes here -->
<?php } else { ?>
 <!-- another html goes here -->
<?php } ?>

Example with the use of echo (using ony one php tag to open/close the block)

<?php  if ( condition ) { 
 echo "<p>Some text content</p>";
    } else { 
 echo "<p>Another text content</p>";
 } ?>

1

solved How to use the php if statement [closed]