By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,776 Members | 1,397 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,776 IT Pros & Developers. It's quick & easy.

Any suggestions about (quotes or <? ?>)

P: n/a
Hello again....
I am coding php in dreamweaver. And because I like to use it for the HTML
parts I want my HTML code to be unquoted and not into echo statements.

BUT I ended up in something like this
<? if ($blabla == 1) { ?>
<h1> blabla is one <h1>
<? }
elseif ($bloublou == 2) { ?>
<form>
<input value= <? echo $var ?> ..... >
</form>
<ul><? do { ?> <li><h4><? etc..... ?>

Anyway what I want to know is how can I safely enclose my whole html code
into an echo statement or anything like echo.

Jul 17 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
On Fri, 20 May 2005 20:32:10 GMT, "Angelos" <ad**********@redcatmedia.net>
wrote:
Hello again....
I am coding php in dreamweaver. And because I like to use it for the HTML
parts I want my HTML code to be unquoted and not into echo statements.

BUT I ended up in something like this
<? if ($blabla == 1) { ?>
<h1> blabla is one <h1>
<? }
elseif ($bloublou == 2) { ?>
<form>
<input value= <? echo $var ?> ..... >
</form>
<ul><? do { ?> <li><h4><? etc..... ?>

Anyway what I want to know is how can I safely enclose my whole html code
into an echo statement or anything like echo.


There's heredoc syntax, such as:

print <<<END_HTML
<input type='text' value='$somevariable'>
END_HTML;

Or you could use the alternative control structure syntax which looks neater
for this sort of layout:

<?php if ($blabla == 1): ?>
<h1>blabla is one<h1>
<?php endif; ?>

Or just put the whole lot in a multi-line echo if you really want, but watch
out for quotes.

--
Andy Hassall / <an**@andyh.co.uk> / <http://www.andyh.co.uk>
<http://www.andyhsoftware.co.uk/space> Space: disk usage analysis tool
Jul 17 '05 #2

P: n/a
> Hello again....
I am coding php in dreamweaver. And because I like to use it for the HTML
parts I want my HTML code to be unquoted and not into echo statements.

BUT I ended up in something like this
<? if ($blabla == 1) { ?>
<h1> blabla is one <h1>
<? }
elseif ($bloublou == 2) { ?>
<form>
<input value= <? echo $var ?> ..... >
</form>
<ul><? do { ?> <li><h4><? etc..... ?>

Anyway what I want to know is how can I safely enclose my whole html code
into an echo statement or anything like echo.


Look at PEAR HTML Templates- http://pear.php.net/package/HTML_Template_IT -
they allow you to completely separate your HTML and PHP code.
Jul 17 '05 #3

P: n/a
Angelos wrote:
Hello again....
I am coding php in dreamweaver. And because I like to use it for the HTML
parts I want my HTML code to be unquoted and not into echo statements.

BUT I ended up in something like this
<? if ($blabla == 1) { ?>
<h1> blabla is one <h1>
<? }
elseif ($bloublou == 2) { ?>
<form>
<input value= <? echo $var ?> ..... >
</form>
<ul><? do { ?> <li><h4><? etc..... ?>


Also, please note that with XHTML 1.0 requires you to quote all
attributes you have in your html. So your <input ...> should actually be:

<input value="<? echo $var; ?>" ....>

See reference at:
http://www.w3.org/TR/xhtml1/#h-4.4

/Marcin
Jul 17 '05 #4

P: n/a
On 23/05/2005 12:52, Marcin Dobrucki wrote:

[snip]
Also, please note that with XHTML 1.0 requires you to quote all
attributes you have in your html.


That would have been better written as: XHTML requires you, as an
author, to quote all attributes in your markup. XHTML has no impact on
HTML, though it is good practice (in my opinion) to quote all attributes
and include optional tags.

However, where did the OP mention the use of XHTML? The errors in the
posted markup means it doesn't conform to any markup language, let alone
hint at the strict requirements of XHTML.

[snip]

Mike

--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail.
Jul 17 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.