Board index   FAQ   Search  
Register  Login
Board index php forum :: HTML HTML Basics

if function in php ( combine php and html)

Discussing Html . Code , Software , other

Moderators: macek, egami, gesf

if function in php ( combine php and html)

Postby bashebashe » Sun Sep 19, 2010 8:54 pm

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, :)
bashebashe
New php-forum User
New php-forum User
 
Posts: 1
Joined: Sun Sep 19, 2010 8:45 pm

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

Postby macek » Sun Sep 19, 2010 9:15 pm

Code: Select all
<?php

if(Statement) {

  echo 'SOME <b>HTML</b>';

} else {

  echo 'ANY OTHER </b>HTML</b>';

}

?>
User avatar
macek
php-forum Active User
php-forum Active User
 
Posts: 277
Joined: Wed Aug 25, 2010 10:42 am

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

Postby perseadrian » Sun Oct 03, 2010 5:46 am

<?php if(Statement) { ?>
<b>Some HTML</b>
<?php } else { ?>
<b>Other HTML</b>
<?php } ?>
perseadrian
New php-forum User
New php-forum User
 
Posts: 1
Joined: Sun Oct 03, 2010 5:32 am


Return to HTML Basics

Who is online

Users browsing this forum: No registered users and 2 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.

cron