You are here: Re: How to write a PHP file if a lot of HTML stuff is within e.g. an 'if' statement « All PHP « IT news, forums, messages
Re: How to write a PHP file if a lot of HTML stuff is within e.g. an 'if' statement

Posted by Dasdan on 02/03/06 20:51

> In general a PHP file has HTML and PHP parts and looks like
> ...
> <tr>
> <td width = "100%">
> <div class = "style_data">
> <?php
> $_SESSION['session_data'] = date("d.m.Y") . " " . date("H:i:s");
> echo $_SESSION['session_date'];
> ?>
> </div>
> </td>
>
> <td width = "100%">
> <input type = "text" name = "my_input" value = "" onMouseover =
> "className = 'style_mouseover'">
> </td>
> </tr>
> ...
>
> But how do I have to write a PHP file if a lot of HTML stuff is within e.g.
> an 'if' statement?
> ...
> <?php
> if ($_SESSION['session_permission'] == true) {
> echo "<tr>";
> echo "<td width = '100%'>";
> echo "<div class = 'style_data'>";
> $_SESSION['session_data'] = date("d.m.Y") . " " . date("H:i:s");
> echo $_SESSION['session_date'];
> echo "</div>";
> echo "</td>";
> echo "<td width = '100%'>";
> echo "<input type = 'text' name = 'my_input' value = '' onMouseover =
> \"className = 'style_mouseover'\">";
> echo "</td>";
> echo "</tr>";
> }
> ?>
> ...
>
> It's quite laborious to write 'echo' before each HTML statement and it's also
> quite tricky with '"' ('\"') e.g. within onMouseover.
>
> Is it somehow possible to use plain HTML statements (without 'echo') within
> PHP (<?php ... ?>)?
> Stefan


you should also take a look at the heredoc syntax:

http://be.php.net/manual/en/language.types.string.php#language.types.string.syntax.heredoc




--
http://www.dasdan.be

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация