if function in php ( combine php and html)

HTML, CSS and anything else that deals with client side capabilities.

Moderator: General Moderators

Post Reply
bashebashe
Forum Newbie
Posts: 1
Joined: Sun Sep 19, 2010 11:58 pm

if function in php ( combine php and html)

Post by bashebashe »

hi to all,

I wanted to combine if function(php) with html as i say below:

e.g.

<?php if(Statement) ?>
Action1
<?php else ?>
Action2
<?php ; ?>

means if 'Statement' is done, Action1 will happen , else Action2 will happen, which both of Action1 and Action2 are html codes,
can anyone tell me how to change the code , so the code will have this property??

Regards, :)
aravona
Forum Contributor
Posts: 347
Joined: Sat Jun 13, 2009 3:59 pm
Location: England

Re: if function in php ( combine php and html)

Post by aravona »

you mean like:

<?php
$x=1;
if ($x == '1'){
?>
<strong> hello </strong> <!-- or whatever code -->
<?php
}
else {
?>
<strong> goodbye </strong> <!-- or whatever code -->
<?php
}
// end of if-else statement
?>
Post Reply