Re: [PHP] 'Pure' php vs 'mixed' (html + php)

2002-06-03 Thread Martín Marqués

On Dom 02 Jun 2002 21:45, David Freeman wrote:
   I've noticed that many people on the list code in 'pure' php, i.e.
  
   ?
   print input type='text' name='fname' size='50';
  
   // etc
   ?

 Personally, it depends on what I'm doing.  I find that excessive use of
 ? And ? in my code gets distracting so if I need a lot of php code I
 will usually put the straight html into echo/print strings.  If I'm
 doing something that is predominantly html with only a few php variables
 or some such then I'll do it mostly in html.

 Often if there's just a php code block I'll move it into an include and
 then just include it in normal html.  This helps readability and lets me
 separate some of the layout aspects from the code logic aspects.

 In the end if it's valid it will work.  My only real decision is based
 on readability for my own purposes.

See the HTML template class that comes with PEAR!

Saludos... :-)

-- 
Porqué usar una base de datos relacional cualquiera,
si podés usar PostgreSQL?
-
Martín Marqués  |[EMAIL PROTECTED]
Programador, Administrador, DBA |   Centro de Telematica
   Universidad Nacional
del Litoral
-

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] 'Pure' php vs 'mixed' (html + php)

2002-06-02 Thread Andre Dubuc

I've noticed that many people on the list code in 'pure' php, i.e.

?
print input type='text' name='fname' size='50';

// etc
?

Since most of my code is a mixture (the early stuff is 'mixed' html + php), 
I've been wondering why code in 'pure' php? Is there some compelling reason 
(that I'm unaware of) for doing so? Should I rewrite all my earlier code into 
its 'pure' form? If so, what do I do with the '! DOCTYPE . . .  statement 
-- put it in quotes too?

I would like to understand the reasons for writing code in this manner, when 
all my code works fine, displays great: am I missing something important 
here? Btw, I use the 'php' ending for all file names.

Your thoughts, opinions and suggestions would be greatly appreciated -- I'd 
like to do what is best.

Tia,
Andre

-- 
Please pray the Holy Rosary to end the holocaust of abortion.
Remember in your prayers the Holy Souls in Purgatory.

May God bless you abundantly in His love!
For a free Cenacle Scriptural Rosary Booklet: http://www.webhart.net/csrb/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] 'Pure' php vs 'mixed' (html + php)

2002-06-02 Thread Bogdan Stancescu

No *real* reason - just two not-so-important ones:

1. Clarity
Please compare these two:
-- MIXED
td bgcolor=?php echo $td_col; ? class=?php echo $prefclass; ?
?php $fldcontent=$myrow[0]?$myrow[0]:no data; ?
input type=text name=fname size=50 value=?php echo $fldcontent; 
?
/td

-- PURE
?php
  echo(td bgcolor='$td_col' class='$prefclass'\n);
  $fldcontent=$myrow[0]?$myrow[0]:no data;
  echo(input type='text' name='fname' size='50' value='$fldcontent'\n);
?

The second is much easier to read and understand, you must agree.

2. Speed
There's an urban legend saying that switching php tags on and off would 
slow parsing down. I don't know if that's true and try to write pure 
php as you call it due to the first reason.

Bogdan

Andre Dubuc wrote:

I've noticed that many people on the list code in 'pure' php, i.e.

?
print input type='text' name='fname' size='50';

// etc
?

Since most of my code is a mixture (the early stuff is 'mixed' html + php), 
I've been wondering why code in 'pure' php? Is there some compelling reason 
(that I'm unaware of) for doing so? Should I rewrite all my earlier code into 
its 'pure' form? If so, what do I do with the '! DOCTYPE . . .  statement 
-- put it in quotes too?

I would like to understand the reasons for writing code in this manner, when 
all my code works fine, displays great: am I missing something important 
here? Btw, I use the 'php' ending for all file names.

Your thoughts, opinions and suggestions would be greatly appreciated -- I'd 
like to do what is best.

Tia,
Andre

  





-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] 'Pure' php vs 'mixed' (html + php)

2002-06-02 Thread Andre Dubuc

Thanks Bogdan,

That's what I thought, but I was beginning to feel 'guilty' the more I 
understood php. It seems to me, from my limited experience, that there's much 
mor chance for error using 'pure' php (as in forgetting ' or  or closing 
with ; -- but . . . 

Actually I've found that the 'mixed' is easier to read and understand -- less 
quotes, less 'print' to read with every line. But that's just personal taste 
on my part.

While I'm at it, I've also noticed that coders tend to integrate 'result' 
pages with the 'calling' page. (That is, I have a text input, and use a php 
function to verify it on the same page). I've tended to keep them separate 
for de-bugging purposes. Should I consider re-writing them as well?

Regards,
Andre

On Sunday 02 June 2002 08:16 pm, you wrote:
 No *real* reason - just two not-so-important ones:

 1. Clarity
 Please compare these two:
 -- MIXED
 td bgcolor=?php echo $td_col; ? class=?php echo $prefclass; ?
 ?php $fldcontent=$myrow[0]?$myrow[0]:no data; ?
 input type=text name=fname size=50 value=?php echo $fldcontent;
 ?
 /td

 -- PURE
 ?php
   echo(td bgcolor='$td_col' class='$prefclass'\n);
   $fldcontent=$myrow[0]?$myrow[0]:no data;
   echo(input type='text' name='fname' size='50' value='$fldcontent'\n);
 ?

 The second is much easier to read and understand, you must agree.

 2. Speed
 There's an urban legend saying that switching php tags on and off would
 slow parsing down. I don't know if that's true and try to write pure
 php as you call it due to the first reason.

 Bogdan

 Andre Dubuc wrote:
 I've noticed that many people on the list code in 'pure' php, i.e.
 
 ?
 print input type='text' name='fname' size='50';
 
 // etc
 ?
 
 Since most of my code is a mixture (the early stuff is 'mixed' html +
  php), I've been wondering why code in 'pure' php? Is there some
  compelling reason (that I'm unaware of) for doing so? Should I rewrite
  all my earlier code into its 'pure' form? If so, what do I do with the
  '! DOCTYPE . . .  statement -- put it in quotes too?
 
 I would like to understand the reasons for writing code in this manner,
  when all my code works fine, displays great: am I missing something
  important here? Btw, I use the 'php' ending for all file names.
 
 Your thoughts, opinions and suggestions would be greatly appreciated --
  I'd like to do what is best.
 
 Tia,
 Andre

-- 
Please pray the Holy Rosary to end the holocaust of abortion.
Remember in your prayers the Holy Souls in Purgatory.

May God bless you abundantly in His love!
For a free Cenacle Scriptural Rosary Booklet: http://www.webhart.net/csrb/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] 'Pure' php vs 'mixed' (html + php)

2002-06-02 Thread Andre Dubuc

On Sunday 02 June 2002 08:13 pm, you wrote:
 On Sun, Jun 02, 2002 at 07:55:09PM -0400, Andre Dubuc wrote:
  I've noticed that many people on the list code in 'pure' php, i.e.
 
  ?
  print input type='text' name='fname' size='50';
 
  // etc
  ?
 
  Since most of my code is a mixture (the early stuff is 'mixed' html +
  php), I've been wondering why code in 'pure' php? Is there some
  compelling reason (that I'm unaware of) for doing so? Should I rewrite
  all my earlier code into its 'pure' form? If so, what do I do with the
  '! DOCTYPE . . .  statement -- put it in quotes too?
 
  I would like to understand the reasons for writing code in this manner,
  when all my code works fine, displays great: am I missing something
  important here? Btw, I use the 'php' ending for all file names.
 
  Your thoughts, opinions and suggestions would be greatly appreciated --
  I'd like to do what is best.
 
  Tia,
  Andre

 ---end quoted text---

 I don't know, but i prefer coding in mixed way.. to avoid excessive
 escaping at html tags and other..

 []'s


Thanks Marcelo,

Precisely my feelings as well. Looks cleaner since I can spot the divisions 
quite readily (no print . . .  ; in the code).

Regards,
Andre


-- 
Please pray the Holy Rosary to end the holocaust of abortion.
Remember in your prayers the Holy Souls in Purgatory.

May God bless you abundantly in His love!
For a free Cenacle Scriptural Rosary Booklet: http://www.webhart.net/csrb/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] 'Pure' php vs 'mixed' (html + php)

2002-06-02 Thread Bogdan Stancescu

I'm not sure what you mean... Is it checking that you fill in the 
correct values via PHP or that the submission works - or something else?

Bogdan

Andre Dubuc wrote:

Thanks Bogdan,

That's what I thought, but I was beginning to feel 'guilty' the more I 
understood php. It seems to me, from my limited experience, that there's much 
mor chance for error using 'pure' php (as in forgetting ' or  or closing 
with ; -- but . . . 

Actually I've found that the 'mixed' is easier to read and understand -- less 
quotes, less 'print' to read with every line. But that's just personal taste 
on my part.

While I'm at it, I've also noticed that coders tend to integrate 'result' 
pages with the 'calling' page. (That is, I have a text input, and use a php 
function to verify it on the same page). I've tended to keep them separate 
for de-bugging purposes. Should I consider re-writing them as well?

Regards,
Andre

On Sunday 02 June 2002 08:16 pm, you wrote:
  

No *real* reason - just two not-so-important ones:

1. Clarity
Please compare these two:
-- MIXED
td bgcolor=?php echo $td_col; ? class=?php echo $prefclass; ?
?php $fldcontent=$myrow[0]?$myrow[0]:no data; ?
input type=text name=fname size=50 value=?php echo $fldcontent;
?
/td

-- PURE
?php
  echo(td bgcolor='$td_col' class='$prefclass'\n);
  $fldcontent=$myrow[0]?$myrow[0]:no data;
  echo(input type='text' name='fname' size='50' value='$fldcontent'\n);
?

The second is much easier to read and understand, you must agree.

2. Speed
There's an urban legend saying that switching php tags on and off would
slow parsing down. I don't know if that's true and try to write pure
php as you call it due to the first reason.

Bogdan

Andre Dubuc wrote:


I've noticed that many people on the list code in 'pure' php, i.e.

?
print input type='text' name='fname' size='50';

// etc
?

Since most of my code is a mixture (the early stuff is 'mixed' html +
php), I've been wondering why code in 'pure' php? Is there some
compelling reason (that I'm unaware of) for doing so? Should I rewrite
all my earlier code into its 'pure' form? If so, what do I do with the
'! DOCTYPE . . .  statement -- put it in quotes too?

I would like to understand the reasons for writing code in this manner,
when all my code works fine, displays great: am I missing something
important here? Btw, I use the 'php' ending for all file names.

Your thoughts, opinions and suggestions would be greatly appreciated --
I'd like to do what is best.

Tia,
Andre
  


  





-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] 'Pure' php vs 'mixed' (html + php)

2002-06-02 Thread Michael Davey

However...

From the point of view of someone who has worked in a company where diesign
is separated from development, it is much better to have separate files with
HTML templates with special markers (in the library I use, it is HTML
comments !--element_to_replace--) so that the two processes are adequately
separated.

When all of the HTML is embedded in PHP staements, minor changes to HTML
layout involve a PHP developer, whereas with template based strategies all
they have to do is change the template.

I believe that 'smarty' is the approved template libray, but there are
several other worth investigating.

Mikey
Bogdan Stancescu [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 No *real* reason - just two not-so-important ones:

 1. Clarity
 Please compare these two:
 -- MIXED
 td bgcolor=?php echo $td_col; ? class=?php echo $prefclass; ?
 ?php $fldcontent=$myrow[0]?$myrow[0]:no data; ?
 input type=text name=fname size=50 value=?php echo $fldcontent;
 ?
 /td

 -- PURE
 ?php
   echo(td bgcolor='$td_col' class='$prefclass'\n);
   $fldcontent=$myrow[0]?$myrow[0]:no data;
   echo(input type='text' name='fname' size='50'
value='$fldcontent'\n);
 ?

 The second is much easier to read and understand, you must agree.

 2. Speed
 There's an urban legend saying that switching php tags on and off would
 slow parsing down. I don't know if that's true and try to write pure
 php as you call it due to the first reason.

 Bogdan

 Andre Dubuc wrote:

 I've noticed that many people on the list code in 'pure' php, i.e.
 
 ?
 print input type='text' name='fname' size='50';
 
 // etc
 ?
 
 Since most of my code is a mixture (the early stuff is 'mixed' html +
php),
 I've been wondering why code in 'pure' php? Is there some compelling
reason
 (that I'm unaware of) for doing so? Should I rewrite all my earlier code
into
 its 'pure' form? If so, what do I do with the '! DOCTYPE . . . 
statement
 -- put it in quotes too?
 
 I would like to understand the reasons for writing code in this manner,
when
 all my code works fine, displays great: am I missing something important
 here? Btw, I use the 'php' ending for all file names.
 
 Your thoughts, opinions and suggestions would be greatly appreciated --
I'd
 like to do what is best.
 
 Tia,
 Andre
 
 
 






-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] 'Pure' php vs 'mixed' (html + php)

2002-06-02 Thread Andre Dubuc

That's what I meant. I was referring to verification/validation scripts for 
user inputs. I've made a separate page that runs these routines. I have a 
feeling I should have incorporated them on the user input page  . . . but 
does it really amtter if they're on another page?

Andre

On Sunday 02 June 2002 08:32 pm, you wrote:
 I'm not sure what you mean... Is it checking that you fill in the
 correct values via PHP or that the submission works - or something else?

 Bogdan

 Andre Dubuc wrote:
 Thanks Bogdan,
 
 That's what I thought, but I was beginning to feel 'guilty' the more I
 understood php. It seems to me, from my limited experience, that there's
  much mor chance for error using 'pure' php (as in forgetting ' or  or
  closing with ; -- but . . .
 
 Actually I've found that the 'mixed' is easier to read and understand --
  less quotes, less 'print' to read with every line. But that's just
  personal taste on my part.
 
 While I'm at it, I've also noticed that coders tend to integrate 'result'
 pages with the 'calling' page. (That is, I have a text input, and use a
  php function to verify it on the same page). I've tended to keep them
  separate for de-bugging purposes. Should I consider re-writing them as
  well?
 
 Regards,
 Andre
 
 On Sunday 02 June 2002 08:16 pm, you wrote:
 No *real* reason - just two not-so-important ones:
 
 1. Clarity
 Please compare these two:
 -- MIXED
 td bgcolor=?php echo $td_col; ? class=?php echo $prefclass; ?
 ?php $fldcontent=$myrow[0]?$myrow[0]:no data; ?
 input type=text name=fname size=50 value=?php echo $fldcontent;
 ?
 /td
 
 -- PURE
 ?php
   echo(td bgcolor='$td_col' class='$prefclass'\n);
   $fldcontent=$myrow[0]?$myrow[0]:no data;
   echo(input type='text' name='fname' size='50'
  value='$fldcontent'\n); ?
 
 The second is much easier to read and understand, you must agree.
 
 2. Speed
 There's an urban legend saying that switching php tags on and off would
 slow parsing down. I don't know if that's true and try to write pure
 php as you call it due to the first reason.
 
 Bogdan
 
 Andre Dubuc wrote:
 I've noticed that many people on the list code in 'pure' php, i.e.
 
 ?
 print input type='text' name='fname' size='50';
 
 // etc
 ?
 
 Since most of my code is a mixture (the early stuff is 'mixed' html +
 php), I've been wondering why code in 'pure' php? Is there some
 compelling reason (that I'm unaware of) for doing so? Should I rewrite
 all my earlier code into its 'pure' form? If so, what do I do with the
 '! DOCTYPE . . .  statement -- put it in quotes too?
 
 I would like to understand the reasons for writing code in this manner,
 when all my code works fine, displays great: am I missing something
 important here? Btw, I use the 'php' ending for all file names.
 
 Your thoughts, opinions and suggestions would be greatly appreciated --
 I'd like to do what is best.
 
 Tia,
 Andre

-- 
Please pray the Holy Rosary to end the holocaust of abortion.
Remember in your prayers the Holy Souls in Purgatory.

May God bless you abundantly in His love!
For a free Cenacle Scriptural Rosary Booklet: http://www.webhart.net/csrb/


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] 'Pure' php vs 'mixed' (html + php)

2002-06-02 Thread Simon Troup

I would ask the question How much HTML before you break out of PHP and into
HTML. My answer is any. Surely you're making the engine work just to echo
stuff out? But are you asking for more by making it jump in and out between
all those tags?!

Short tags ...

td bgcolor=?=$td_col? class=?=$prefclass?

... easier to read in Mixed? I think so.

Also, pure coding breaks the HTML syntax coloring in my text editor!

Simon

 Thanks Bogdan,
 
 That's what I thought, but I was beginning to feel 'guilty' the more I
 understood php. It seems to me, from my limited experience, that there's much
 mor chance for error using 'pure' php (as in forgetting ' or  or closing
 with ; -- but . . .
 
 Actually I've found that the 'mixed' is easier to read and understand -- less
 quotes, less 'print' to read with every line. But that's just personal taste
 on my part.
 
 While I'm at it, I've also noticed that coders tend to integrate 'result'
 pages with the 'calling' page. (That is, I have a text input, and use a php
 function to verify it on the same page). I've tended to keep them separate
 for de-bugging purposes. Should I consider re-writing them as well?
 
 Regards,
 Andre
 
 On Sunday 02 June 2002 08:16 pm, you wrote:
 No *real* reason - just two not-so-important ones:
 
 1. Clarity
 Please compare these two:
 -- MIXED
 td bgcolor=?php echo $td_col; ? class=?php echo $prefclass; ?
 ?php $fldcontent=$myrow[0]?$myrow[0]:no data; ?
 input type=text name=fname size=50 value=?php echo $fldcontent;
 ?
 /td
 
 -- PURE
 ?php
 echo(td bgcolor='$td_col' class='$prefclass'\n);
 $fldcontent=$myrow[0]?$myrow[0]:no data;
 echo(input type='text' name='fname' size='50' value='$fldcontent'\n);
 ?
 
 The second is much easier to read and understand, you must agree.
 
 2. Speed
 There's an urban legend saying that switching php tags on and off would
 slow parsing down. I don't know if that's true and try to write pure
 php as you call it due to the first reason.
 
 Bogdan
 
 Andre Dubuc wrote:
 I've noticed that many people on the list code in 'pure' php, i.e.
 
 ?
 print input type='text' name='fname' size='50';
 
 // etc
 ?
 
 Since most of my code is a mixture (the early stuff is 'mixed' html +
 php), I've been wondering why code in 'pure' php? Is there some
 compelling reason (that I'm unaware of) for doing so? Should I rewrite
 all my earlier code into its 'pure' form? If so, what do I do with the
 '! DOCTYPE . . .  statement -- put it in quotes too?
 
 I would like to understand the reasons for writing code in this manner,
 when all my code works fine, displays great: am I missing something
 important here? Btw, I use the 'php' ending for all file names.
 
 Your thoughts, opinions and suggestions would be greatly appreciated --
 I'd like to do what is best.
 
 Tia,
 Andre


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] 'Pure' php vs 'mixed' (html + php)

2002-06-02 Thread Andre Dubuc

Thanks Michael,

Point well-made. I suppose doing it the mixed way might have repercussions 
later on if/when the site grows. Perhaps while the code is still fresh in my 
mid, it might be worth the effort to separate it.

However, for a good part of the site, I've used CSS for appearance details, 
and controlling a lot of stuff that changes from page-to-page. It's very easy 
to change all or some of the pages from the CSS scripts. But, for the most 
part, not much of the actual php scripts COULD change, so that's why I've 
never bothered to separate html from php. Perhaps I wrong, but  . . .

Regards,
Andre

On Sunday 02 June 2002 08:36 pm, you wrote:
 However...

 From the point of view of someone who has worked in a company where diesign
 is separated from development, it is much better to have separate files
 with HTML templates with special markers (in the library I use, it is HTML
 comments !--element_to_replace--) so that the two processes are
 adequately separated.

 When all of the HTML is embedded in PHP staements, minor changes to HTML
 layout involve a PHP developer, whereas with template based strategies all
 they have to do is change the template.

 I believe that 'smarty' is the approved template libray, but there are
 several other worth investigating.

 Mikey
 Bogdan Stancescu [EMAIL PROTECTED] wrote in message
 [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...

  No *real* reason - just two not-so-important ones:
 
  1. Clarity
  Please compare these two:
  -- MIXED
  td bgcolor=?php echo $td_col; ? class=?php echo $prefclass; ?
  ?php $fldcontent=$myrow[0]?$myrow[0]:no data; ?
  input type=text name=fname size=50 value=?php echo $fldcontent;
  ?
  /td
 
  -- PURE
  ?php
echo(td bgcolor='$td_col' class='$prefclass'\n);
$fldcontent=$myrow[0]?$myrow[0]:no data;
echo(input type='text' name='fname' size='50'

 value='$fldcontent'\n);

  ?
 
  The second is much easier to read and understand, you must agree.
 
  2. Speed
  There's an urban legend saying that switching php tags on and off would
  slow parsing down. I don't know if that's true and try to write pure
  php as you call it due to the first reason.
 
  Bogdan
 
  Andre Dubuc wrote:
  I've noticed that many people on the list code in 'pure' php, i.e.
  
  ?
  print input type='text' name='fname' size='50';
  
  // etc
  ?
  
  Since most of my code is a mixture (the early stuff is 'mixed' html +

 php),

  I've been wondering why code in 'pure' php? Is there some compelling

 reason

  (that I'm unaware of) for doing so? Should I rewrite all my earlier code

 into

  its 'pure' form? If so, what do I do with the '! DOCTYPE . . . 

 statement

  -- put it in quotes too?
  
  I would like to understand the reasons for writing code in this manner,

 when

  all my code works fine, displays great: am I missing something important
  here? Btw, I use the 'php' ending for all file names.
  
  Your thoughts, opinions and suggestions would be greatly appreciated --

 I'd

  like to do what is best.
  
  Tia,
  Andre

-- 
Please pray the Holy Rosary to end the holocaust of abortion.
Remember in your prayers the Holy Souls in Purgatory.

May God bless you abundantly in His love!
For a free Cenacle Scriptural Rosary Booklet: http://www.webhart.net/csrb/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] 'Pure' php vs 'mixed' (html + php)

2002-06-02 Thread David Freeman


  I've noticed that many people on the list code in 'pure' php, i.e.
  
  ?
  print input type='text' name='fname' size='50';
  
  // etc
  ?

Personally, it depends on what I'm doing.  I find that excessive use of
? And ? in my code gets distracting so if I need a lot of php code I
will usually put the straight html into echo/print strings.  If I'm
doing something that is predominantly html with only a few php variables
or some such then I'll do it mostly in html.

Often if there's just a php code block I'll move it into an include and
then just include it in normal html.  This helps readability and lets me
separate some of the layout aspects from the code logic aspects.

In the end if it's valid it will work.  My only real decision is based
on readability for my own purposes.

CYA, Dave



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] 'Pure' php vs 'mixed' (html + php)

2002-06-02 Thread Bogdan Stancescu

No, it doesn't - just go with whatever's simpler for you... and with 
what matches your application better - I don't think this does matter at 
all.

Bogdan

Andre Dubuc wrote:

That's what I meant. I was referring to verification/validation scripts for 
user inputs. I've made a separate page that runs these routines. I have a 
feeling I should have incorporated them on the user input page  . . . but 
does it really amtter if they're on another page?

Andre

On Sunday 02 June 2002 08:32 pm, you wrote:
  

I'm not sure what you mean... Is it checking that you fill in the
correct values via PHP or that the submission works - or something else?

Bogdan

Andre Dubuc wrote:


Thanks Bogdan,

That's what I thought, but I was beginning to feel 'guilty' the more I
understood php. It seems to me, from my limited experience, that there's
much mor chance for error using 'pure' php (as in forgetting ' or  or
closing with ; -- but . . .

Actually I've found that the 'mixed' is easier to read and understand --
less quotes, less 'print' to read with every line. But that's just
personal taste on my part.

While I'm at it, I've also noticed that coders tend to integrate 'result'
pages with the 'calling' page. (That is, I have a text input, and use a
php function to verify it on the same page). I've tended to keep them
separate for de-bugging purposes. Should I consider re-writing them as
well?

Regards,
Andre

On Sunday 02 June 2002 08:16 pm, you wrote:
  

No *real* reason - just two not-so-important ones:

1. Clarity
Please compare these two:
-- MIXED
td bgcolor=?php echo $td_col; ? class=?php echo $prefclass; ?
?php $fldcontent=$myrow[0]?$myrow[0]:no data; ?
input type=text name=fname size=50 value=?php echo $fldcontent;
?
/td

-- PURE
?php
 echo(td bgcolor='$td_col' class='$prefclass'\n);
 $fldcontent=$myrow[0]?$myrow[0]:no data;
 echo(input type='text' name='fname' size='50'
value='$fldcontent'\n); ?

The second is much easier to read and understand, you must agree.

2. Speed
There's an urban legend saying that switching php tags on and off would
slow parsing down. I don't know if that's true and try to write pure
php as you call it due to the first reason.

Bogdan

Andre Dubuc wrote:


I've noticed that many people on the list code in 'pure' php, i.e.

?
print input type='text' name='fname' size='50';

// etc
?

Since most of my code is a mixture (the early stuff is 'mixed' html +
php), I've been wondering why code in 'pure' php? Is there some
compelling reason (that I'm unaware of) for doing so? Should I rewrite
all my earlier code into its 'pure' form? If so, what do I do with the
'! DOCTYPE . . .  statement -- put it in quotes too?

I would like to understand the reasons for writing code in this manner,
when all my code works fine, displays great: am I missing something
important here? Btw, I use the 'php' ending for all file names.

Your thoughts, opinions and suggestions would be greatly appreciated --
I'd like to do what is best.

Tia,
Andre
  


  





-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] 'Pure' php vs 'mixed' (html + php)

2002-06-02 Thread Bogdan Stancescu

I fell for this some time ago - but the trick is that
1. You don't do for ($i=0; $i999; $i++) { echo Line $ibr\n; 
} in real life - you do stuff, call object methods, run queries, 
whatever, and in between those you have both html and php - and the 
remote machine waits for you to do all the extra stuff and _then_ 
waits for you to switch in and out of php for several times. I'm 
thinking about switching in and out of php in a really-mixed context - 
such as having blocks of html inside if() and while() blocks, stuff like 
that where you get to parse quite a number of php tags.
2. Your server doesn't only serve one client at a time - I'm surprised 
that you're starting with commercial sites and this piece of information 
isn't *always* present in your mind.

However, as I said in my original mail, there's an urban legend saying 
that [...] I don't know if that's true. So... I don't know if it 
actually slows things down or not.

Bogdan

Marcelo Leitner wrote:

On Mon, Jun 03, 2002 at 03:16:10AM +0300, Bogdan Stancescu wrote:
  

2. Speed
There's an urban legend saying that switching php tags on and off would 
slow parsing down. I don't know if that's true and try to write pure 
php as you call it due to the first reason.



I don't mind about this.. I'm starting with comercial pages now and before that
I noted that any script you run at the server, you will only see this latency
if the output is buffered or you have a ultra-fast machine with a
super-powerfull navigator that can renderize the page before it's fully sent to
the browser..
Try doing something like for ($i=0; $i999; $i++) { echo Line $ibr\n; }
Run the script in one machine and the browser at another.. you'll see that the
client machine has the cpu burned much more then the server..
You can see this when you're trying to open that big-flat-forums
all-in-one-page.. you'll get sometime 1. to receive that, 2. to renderize..
Note that you can only see the renderizing time if you're on a fast connection..

What I do take care is about excessive database searchs.. that can slow down
the things since I'll probably will not have a reserved server..

  

Bogdan


---end quoted text---

[]'s
  





-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] 'Pure' php vs 'mixed' (html + php)

2002-06-02 Thread Michael Davey

 Point well-made. I suppose doing it the mixed way might have repercussions
 later on if/when the site grows. Perhaps while the code is still fresh in
my
 mid, it might be worth the effort to separate it.

 However, for a good part of the site, I've used CSS for appearance
details,
 and controlling a lot of stuff that changes from page-to-page. It's very
easy
 to change all or some of the pages from the CSS scripts. But, for the most
 part, not much of the actual php scripts COULD change, so that's why I've
 never bothered to separate html from php. Perhaps I wrong, but  . . .

I think it is a case of horses for courses - you are working on what sounds
like a fairly small project, and templatizing your code may be more
trouble than it is worth, so whatever feels best for you...



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] 'Pure' php vs 'mixed' (html + php)

2002-06-02 Thread Bogdan Stancescu

This whole discussion made me really curious - so you might want to 
check the attachments (access mixtest.php) for a very surprising result 
(please note mixed.php and pure.php are exactly the same size so this 
doesn't affect the test).

Bogdan

Marcelo Leitner wrote:

On Mon, Jun 03, 2002 at 04:42:46AM +0300, Bogdan Stancescu wrote:
  

I fell for this some time ago - but the trick is that
1. You don't do for ($i=0; $i999; $i++) { echo Line $ibr\n; 
} in real life - you do stuff, call object methods, run queries, 
whatever, and in between those you have both html and php - and the 
remote machine waits for you to do all the extra stuff and _then_ 
waits for you to switch in and out of php for several times. I'm 
thinking about switching in and out of php in a really-mixed context - 
such as having blocks of html inside if() and while() blocks, stuff like 
that where you get to parse quite a number of php tags.
2. Your server doesn't only serve one client at a time - I'm surprised 
that you're starting with commercial sites and this piece of information 
isn't *always* present in your mind.

However, as I said in my original mail, there's an urban legend saying 
that [...] I don't know if that's true. So... I don't know if it 
actually slows things down or not.

Bogdan


---end quoted text---

I gave that example to be a create a huge final page with the less time
as possible..
You never do that loop, but what about logfiles analysing? You have tons of
lines, probably splited by day, of all the accesses and whatever were done..
I did a some time ago a database of the itens from a MUD game.. I allowed
users to list the whole database, so they could read that and search for new
items for them.. but each item had 6 lines displayed, without tables or
anything, neither li/li.. only br and p..
when it got about 400 items, my PIII-733 321MB ram got under it's knees to
render that page.. it didn't have any fig or whatever that would need more
time to render..
I now that I'll not have a dedicated http server, but loosing microseconds
at each page on a server that has one thousand accesses per day is nothing..
And even if you're going to have that traffic you'll have better servers
that will deal with that and will probably run more processes at a time, so
a script that is coded slowly wouldn't break the other..
What I don't do is
...
if ($a == $x) { ?
  trtd align=center?echo $a?/td/tr
? } else { ?
  trtd align=right?echo $a?/td/tr
? }
...

That's really ugly! :)

[]'s
  





?
  if ($foo==bar) { ?
tdBla-bla - testing/td
?
$bar=$foo;
?
td?=$bar ?/td?
  }
?


?php
  if ($foo==bar) {
echo(tdBla-bla - testing/td\n);
$bar=$foo;
echo(td$bar/td\n);
  }
?


?php
  ini_set('max_execution_time', 600);
  function gettime() {
list($usec, $sec) = explode( , microtime());
return ((float)$usec + (float)$sec);
  }

  $t1=gettime();
  for ($i=0;$i!=1;$i++) {
include(mixed.php);
  }
  $t2=gettime();
  for ($i=0;$i!=1;$i++) {
include(pure.php);
  }
  $t3=gettime();

  echo(($t2-$t1).s for mixed code;br\n);
  echo(($t3-$t2).s for pure code.br\n);
  echo(round((($t3-$t2)/($t2-$t1)-1)*100,2).% more time used for bPURE/b 
code.br\n);
?



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] 'Pure' php vs 'mixed' (html + php)

2002-06-02 Thread Bogdan Stancescu

I was getting a typical 2.5% more for pure PHP with the original order - 
switching them increases the difference to about 6.5% more for pure PHP. 
Make sure you run it several times before drawing any conclusions, BTW. 
Strange...

Bogdan

Marcelo Leitner wrote:

On Mon, Jun 03, 2002 at 05:18:50AM +0300, Bogdan Stancescu wrote:
  

This whole discussion made me really curious - so you might want to 
check the attachments (access mixtest.php) for a very surprising result 
(please note mixed.php and pure.php are exactly the same size so this 
doesn't affect the test).

Bogdan


---end quoted text---

But try inverting the order of the test, first test the pure, then the
mixed.. they will get almost equal..

[]'s
  





-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php