Hi you experts
As a novice in all this I want to know if what I am doing is silly or bad-practice. You can place a chronoform in an article where you want it with
and it works fine BUT on looking at a tutorial about components I see that the writer stays in html as much as possible and only pops into php for a few bits and back out as soon as possible.
If he makes a table he has <td> <?php echo $myvalue ?> to get a value in the table then </td>. whereas I have written echo "<td> $myvariable </td> etc etc";
I think my way of staying in Php and echoing the html is a lot easier to read but is it wrong or bad practice. If so why ?...I am only learning!
--
Dave
As a novice in all this I want to know if what I am doing is silly or bad-practice. You can place a chronoform in an article where you want it with
{chronocontact} formname {/chronocontact}
. But since I am in php I have putecho "{chronocontact}hiredates5{/chronocontact}";
and it works fine BUT on looking at a tutorial about components I see that the writer stays in html as much as possible and only pops into php for a few bits and back out as soon as possible.
If he makes a table he has <td> <?php echo $myvalue ?> to get a value in the table then </td>. whereas I have written echo "<td> $myvariable </td> etc etc";
I think my way of staying in Php and echoing the html is a lot easier to read but is it wrong or bad practice. If so why ?...I am only learning!
--
Dave
Hi Dave,
It really is a question of taste and a little bit of processor efficiency.
99.9% of websites have under-used servers to efficiency probably isn't a problem.
I tend to write code mostly for readability. This means that I avoid frequent <?php tags and am more likely to use echo than to have lots of embedded <?php echo $xxx; ?>
There are a couple things to be aware of. There is a <?=$xxx?> syntax that is equivalent to the echo string above. It's neat if it works on your server - but it doesn't work on all servers so I avoid it as much of my code is published.
Second, PHP processes anything inside double quotes but skips anything in single quotes so judicious use of the 'right' kind of quote can help e.g. echo 'single quotes around some long text string that can be ignored'."double {$quotes} around {$a_string} that needs {$processing}";
Bob
It really is a question of taste and a little bit of processor efficiency.
99.9% of websites have under-used servers to efficiency probably isn't a problem.
I tend to write code mostly for readability. This means that I avoid frequent <?php tags and am more likely to use echo than to have lots of embedded <?php echo $xxx; ?>
There are a couple things to be aware of. There is a <?=$xxx?> syntax that is equivalent to the echo string above. It's neat if it works on your server - but it doesn't work on all servers so I avoid it as much of my code is published.
Second, PHP processes anything inside double quotes but skips anything in single quotes so judicious use of the 'right' kind of quote can help e.g. echo 'single quotes around some long text string that can be ignored'."double {$quotes} around {$a_string} that needs {$processing}";
Bob
Thanks Bob,
that is very helpful.
I lost some sleep last night trying to decide who does what?
If I write
Or does it read the message, translate the php, and just send N i c e D a y. Or is interpretation the job of the browser at the client end?
Not that it matters but I can see that could affect the choice of style.
#I used to work with 5 hole punched paper tape but moved on to 8 hole later. Then it took 30 mins to load a program!
--
Dave
that is very helpful.
I lost some sleep last night trying to decide who does what?
If I write
<?php echo "Nice Day" ?>
I know the web simply passes what we used to describe as ascii# characters from one place to another. But does it send the characters < ? p h p e c h o " etcOr does it read the message, translate the php, and just send N i c e D a y. Or is interpretation the job of the browser at the client end?
Not that it matters but I can see that could affect the choice of style.
#I used to work with 5 hole punched paper tape but moved on to 8 hole later. Then it took 30 mins to load a program!
--
Dave
Hi Dave,
PHP is executed on the server so what is sent is just the result of the processing - basically what you see if you do View Source on the page. On the other hand JavaScript is executed in the browser.
Bob
I started with punched cards - then graduated to a 120cps paper tape link! Them was the days :-)
PHP is executed on the server so what is sent is just the result of the processing - basically what you see if you do View Source on the page. On the other hand JavaScript is executed in the browser.
Bob
I started with punched cards - then graduated to a 120cps paper tape link! Them was the days :-)
This topic is locked and no more replies can be posted.
