|
Posted by linda on 11/01/06 19:09
"Steve" <no.one@example.com> wrote in message
news:7062h.1$vj4.0@newsfe07.lga...
>| Hi Martin,
> |
> | Thank you for your reply, I've solved it now with a suggestion from
> Steve,
> | but thank you anyway for replying, I am very grateful. Re: the
> structure,
> | I've never been able to decide since starting to learn php whether it is
> | better to print the html or break out of php into html then back in
> again,
> I
> | do know what you mean though it does look a little messy and
> unstructured.
> | Your example definitely makes it easier to read. Point taken, and
> noted.
> | Though with that said, I'd be interested to here others views on this,
> | because as I've stated, I've been on the fence in deciding. And it's
> always
> | useful to know the pros and con's for both, and how others feel. This
> way
> | it will give me a better understanding of which is best. I realise that
> | when you need to print large amounts of html it's better to break out of
> php
> | to do it, but when it comes to the odd table I don't know which is best.
>
> i use this as my guide:
>
> always make sure your html output is sent to the browser in a completely
> well formatted manner. such as indenting parent html nodes and further
> indenting child nodes.
I laugh at this, ;-) when I was purely a html/css writer, I did just that,
but for some reason since I have started with php, I've got lazy. A case of
I think "I want to get the boring html out of the way, so I can get back to
the interesting php", yes it's a very valid point made by both yourself and
Martin. I have got very lazy with this.
> making sure that html output does not require one to wrap text when
> viewing
> source from a page.
>
> (these two will save you ooodles of time trying to debug output...it is
> easy
> to do and makes you look professional in the process).
Yep I can see what you mean!
> as for php, my goal is to have php parse as little as possible. this
> includes using ' instead of " when i am not embedding php variables or
OK yeah, when I first started I used the apostrophe so that i could write
html with double quotes inside php with no errors. Then I just started
using mainly double quotes. Is there a great difference in speed?
> control characters in a string. ex. echo 'hello world', "hello world\n".
> as
> a general rule though, you want to keep your php code seperate from your
> html *as much as possible* and only mingle the two when necessary. btw,
> have
> you heard of "short-tags"? rather than the long, drawn-out method of:
>
Yes but I thought there was a compatibility problem with some of it? And
that if "god forbid" I should have to change hosts and they didn't have
this set up I would then need to re-edit all code. Which is why I stuck
with the <?php instead of the short hand version same with the echoed
variable etc? Which ones are major compatibility problems? As I wasn't
sure, well you get the picture.
> html<? echo $variable; ?>more html
>
> short-tags provide the same output in this form:
>
> html<?= $variable ?>more html
>
> notice the equal sign, the lack of "echo", and the lack of the final
> semi-colon. short-tags are enabled in php by default, but if they don't
> work, you'll have to turn them on either in the php.ini or by calling
> ini_set in your php script/page.
>
OK turning them on is a no go as I don't have access to the ini file, so how
would the second option be implemented into a script?
> any of that help?
Yes Lots!
Best wishes,
Linda
Navigation:
[Reply to this message]
|