Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Selected Reading
Can HTML be embedded inside PHP “if” statement?
Yes, HTML can be embedded inside an ‘if’ statement with the help of PHP. Below are a few methods.
Using the if condition −
<?php if($condition) : ?> <a href="website_name.com">it is displayed iff $condition is met</a> <?php endif; ?>
Using the if and else if conditions −
<?php if($condition) : ?> <a href=" website_name.com "> it is displayed iff $condition is met </a> <?php elseif($another_condition) : ?> HTML TAG HERE <?php else : ?> HTML TAG HERE <?php endif; ?>
Embedding HTML inside PHP −
<?php
if ( $condition met ) {
?> HTML TAG HERE
<?php;
}
?> Advertisements
