Re: [PHP] More thoughts about PHP: Taglibs

2001-09-11 Thread Tim

A good template library (and there's quite a few out there) will take
care of this issue.  You can have nearly pure HTML files and pure PHP
files and maintenance and readability of your projects is much improved.

- Tim
  http://www.phptemplates.org

On Tue, 2001-09-11 at 01:04, Dr. Evil wrote:
 
 It seems to me that one of the problems with PHP is that you have to
 include code in your HTML pages.  Even with the cleanest design, you
 end up with HTML that looks like this:
...



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] More thoughts about PHP: Taglibs

2001-09-11 Thread Michael Kimsal



Dr. Evil wrote:

It seems to me that one of the problems with PHP is that you have to
include code in your HTML pages.  Even with the cleanest design, you
end up with HTML that looks like this:

html
Hello, ?php showusername(); ?.  Your last login was ?php
showlastlogin(); ?.p
/html

No, you don't.  

Have a script file that processes your information, then include() a 
template
file that would have drop in replacements

file1.php
?
$name = showusername();
$login = showlastlogin();
include(template.html);
?

template.html
html
Hello ?=$name;? your last login was ?=$login;?.
/html


Your PHP file can get fancy.
file1.php
?
$template=foo.html;
$name = showusername();
$login = showlastlogin();
if ($login60 days) {
$template=foolate.html;
}
include($template);
?

You can check conditionals, handle errors, etc., in your PHP file,
without putting any function calls in your HTML template.  We
try to avoid putting function calls in the templates at all costs.  
variables - yes.  logic (if/else/etc) - yes (on occasion).  
function calls? No.



This is ok, but it seems to me that java taglibs provide a more
elegant way to do the same things:

html
Hello, showusername/.  Your last login was showlastlogin/.p
/html


Again - what if showlastlogin returned an error for some reason?  How
would you handle that there?

If the 'elegance' is simply saving a few keystrokes, that's not really
doing much.  :(


This lets the backend stuff be completely separated from the html
design part of things.  What do people think of this?  I'm just now
learning JSP so I'm thinking about the differences between PHP and
JSP.

It's not separated enough if you're possibly pulling back stuff from 
functions
which you haven't error checked.  You would do that error checking in the
template then, which doesn't strike me as very efficient in most cases.


In general, both are powerful ways of creating dynamic websites, but
they have different characteristics and are better for different
things.  I'm learning java but I will continue to use both, depending
on the task.




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] More thoughts about PHP: Taglibs

2001-09-10 Thread Dr. Evil


It seems to me that one of the problems with PHP is that you have to
include code in your HTML pages.  Even with the cleanest design, you
end up with HTML that looks like this:

html
Hello, ?php showusername(); ?.  Your last login was ?php
showlastlogin(); ?.p
/html

This is ok, but it seems to me that java taglibs provide a more
elegant way to do the same things:

html
Hello, showusername/.  Your last login was showlastlogin/.p
/html

This lets the backend stuff be completely separated from the html
design part of things.  What do people think of this?  I'm just now
learning JSP so I'm thinking about the differences between PHP and
JSP.

In general, both are powerful ways of creating dynamic websites, but
they have different characteristics and are better for different
things.  I'm learning java but I will continue to use both, depending
on the task.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]