Page 1 of 1

if function in php ( combine php and html)

Posted: Mon Sep 20, 2010 12:01 am
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, :)

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

Posted: Fri Sep 24, 2010 6:21 am
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
?>