Re: [PHP] Couple of beginner questions

2009-01-12 Thread Peter Ford
Paul M Foster wrote:
(snip)
 But here's a question for those of you who work in a collaborative
 environment-- are you really ever in a situation where some HTML weenie
 is coding HTML pages and you're somewhere else doing the PHP work? Or is
 that some academic's view of the way things *should* be done?
 
 Paul

Yup, been there in a mid-sized web agency a few years ago, although with
Java/JSP rather than PHP. The sensitive types drew the pretty pictures on their
Macs, passed the design to the HTML hackers who broke the pretty pictures into
sprawling arrays of table cells and image fragments, then passed the HTML to the
Java teams (me and others) who had to slot in the logic without spoiling the
pretty pictures. Then the sensitive types would see a pixel out of place and the
HTML hackers would have to carefully navigate the logic sections and tweak the
tables to make it look right again.
It certainly focuses the mind about separating logic and presentation. In the
end most of the JSP was done with JSP tag libraries, so that the HTML hackers
were not too distracted by scary Java code.
It actually all worked quite well, and produced some really beautiful web sites
AND really elegant code libraries.
But then the dot-com thing all fell over and it was too expensive for most
people to pay for three teams and a couple of managers just to build a web 
shop...


-- 
Peter Ford  phone: 01580 89
Developer   fax:   01580 893399
Justcroft International Ltd., Staplehurst, Kent

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



Re: [PHP] Couple of beginner questions

2009-01-12 Thread Nathan Rixham

Paul M Foster wrote:

But here's a question for those of you who work in a collaborative
environment-- are you really ever in a situation where some HTML weenie
is coding HTML pages and you're somewhere else doing the PHP work? Or is
that some academic's view of the way things *should* be done?

Paul


yep very frequently, infact I'd say I only work in the display layer 
about 20% of the time now; if that.


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



Re: [PHP] Couple of beginner questions

2009-01-12 Thread Nathan Rixham

Peter Ford wrote:

Paul M Foster wrote:
(snip)

But here's a question for those of you who work in a collaborative
environment-- are you really ever in a situation where some HTML weenie
is coding HTML pages and you're somewhere else doing the PHP work? Or is
that some academic's view of the way things *should* be done?

Paul


Yup, been there in a mid-sized web agency a few years ago, although with
Java/JSP rather than PHP. The sensitive types drew the pretty pictures on their
Macs, passed the design to the HTML hackers who broke the pretty pictures into
sprawling arrays of table cells and image fragments, then passed the HTML to the
Java teams (me and others) who had to slot in the logic without spoiling the
pretty pictures. Then the sensitive types would see a pixel out of place and the
HTML hackers would have to carefully navigate the logic sections and tweak the
tables to make it look right again.
It certainly focuses the mind about separating logic and presentation. In the
end most of the JSP was done with JSP tag libraries, so that the HTML hackers
were not too distracted by scary Java code.
It actually all worked quite well, and produced some really beautiful web sites
AND really elegant code libraries.
But then the dot-com thing all fell over and it was too expensive for most
people to pay for three teams and a couple of managers just to build a web 
shop...




think you've hit on something there; when I'm not coding in php I'm 
coding in java; which has a very strong focus on code seperation and 
using certain architectures / design patterns; it's hard not to cary 
this over to php and other languages once you've started doing it - as 
you say it leads to really beautiful web sites AND really elegant code 
libraries


at the same time though there's the time/effort/cost factors and often 
it's not efficient or cost effective in any way to knock up a perfectly 
coded application for a small-mid sized site. Not that stops me trying / 
picking  choosing the work which allows me the freedom to code properly


ooh, worth noting that using flex as a front end almost by nature forces 
you to use an mvc/3-tier/n-tier architecture :) makes coding much more 
enjoyable.


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



Re: [PHP] Couple of beginner questions

2009-01-12 Thread tedd

At 3:36 PM + 1/11/09, Ashley Sheridan wrote:


 
I was thinking more along the lines of this:

[1] echo img src=\$url\ alt=\$alt\ title=\$alt\ class=\$imgclass
\/;


which looks like this otherwise:

[2] img src=?php echo($url);? alt=?php echo($alt);? title=?php
echo($alt);? class=?php echo($imgclass);?/


Ash:

I see and understand what you are saying.

To me, [2] is more understandable/preferable than [1].

To each their own.

Cheers,

tedd

--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

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



Re: [PHP] Couple of beginner questions

2009-01-12 Thread tedd

At 5:01 PM + 1/11/09, Nathan Rixham wrote:


i love these discussions on pedantics and semantics!
 [and]
keep the layers as seperate as possible


That's the main topic of this thread. But you missed the point of the 
debate. I was claiming that one should not have any html within an 
echo, whereas Ash was showing difficulties in doing so.


For example your:

$imgHTML = 'img src=' . $url . ' alt=' . $alt . ' title=' . 
$alt . ' class=' . $imgclass . ' /';


If given the choice I would not practice. Instead, I would echo each 
variable out such as:


img src=?php echo($url);? ...

however; I only really do this when developing or in a quick bit of 
script; whenever possible I'll always use a templating engine, or 
xml/xsl which is the perfect abstraction between data and 
presentation IMHO.


I've never used a template engine. Attempts at doing so resulted in 
frustration as to how the designers mixed php, css, and html.


another little note is that I'd never echo out a class or 
presentation data; infact I'd never use a class on a tag such as img 
either, preference going to a bit of css using selectors


div#article_content p img {
/* whatever */
}


I see absolutely nothing wrong with using:

?php
$paragraph_class = 'paragraph_class';
...
?

p class=?php echo($paragraph_class)

with the following in an attached css file.

.paragraph_class
   {
   font-size: 1.1em;
   color: #ff;
   margin: .5em;
   }


now I've limitted all presentation to css only, css contained in a 
stylesheet -


Same here.

However, I have changed the application of css style rules via php 
and javascript (DOM scripting). DOM scripting is an exciting and 
wonderful way to change html unobtrusively, but that's beyond this 
discussion.


I try to use minimal css classes, and stick to using an id wherever 
I can't simply redefine the html tag.


Id's are fine provided that you are not going to use more than one 
per page -- otherwise, class is a better choice.



the above means that moving back to the original h1 example(s) I'd simply

h1whatever/h1

css:
h1 {
  color: rgb(255,0,0);
  font-size: 1.2em;
}

seeing as you can only have one h1 tag on a single document.


No, that's not true. You can have as many h1 tags as you want in a 
single document -- they will all just look the same. However, if you 
use classes, then you can have as many h1 tags as you want looking 
the way you want them to look -- much more freedom.


Additionally, there's more to consider here than just the way the 
document looks. To be holistic, one should consider not only how the 
document looks to people, but to bots. If h1 tags are considered 
important to SE bots, and you don't want h1 tags in your document, 
then you are sunk -- unless you style the h1 the way you want them 
to look. As an example, I have used bold tags for SEO concerns 
while showing the user no bold text.


As I said, there's more here than just how a documents looks to a 
human visitor, but that is also beyond this discussion.


Cheers,

tedd

--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

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



Re: [PHP] Couple of beginner questions

2009-01-12 Thread ceo

 $ mv hello-world.php hello-world.html



Isn't this backwards?...



:-)



39% seems awfully high overhead for what is essentially an extra readfile.



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



Re: [PHP] Couple of beginner questions

2009-01-12 Thread tedd

At 12:25 PM -0500 1/11/09, Robert Cummings wrote:

Although, to be honest I tend to vertically
spread my tags/attributes:

$imgHTML =
'img'
   .' src='.$url.''
   .' alt='.$alt.''
   .' title='.$alt.''
   .' class='.$imgclass.''
   .' /';

This makes it easy to see at a glance what is there and to also comment
out lines easily.



I vertically stack variables as well, such as in developing a long 
MySQl $query, but I don't include any html in my echo statements. 
That's just a private rule of mine that is sometimes broken by client 
needs.


Cheers,

tedd


--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

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



Re: [PHP] Couple of beginner questions

2009-01-12 Thread Eric Butera
On Mon, Jan 12, 2009 at 10:16 AM,  c...@l-i-e.com wrote:

 $ mv hello-world.php hello-world.html

 Isn't this backwards?...

 :-)

 39% seems awfully high overhead for what is essentially an extra readfile.


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



Yea, but it's still the same file.  I just copied the wrong line.

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



Re: [PHP] Couple of beginner questions

2009-01-12 Thread Paul M Foster
On Sun, Jan 11, 2009 at 11:28:49PM -0800, Lars Torben Wilson wrote:

 2009/1/11 Paul M Foster pa...@quillandmouse.com:

snip

  But here's a question for those of you who work in a collaborative
  environment-- are you really ever in a situation where some HTML weenie
  is coding HTML pages and you're somewhere else doing the PHP work? Or is
  that some academic's view of the way things *should* be done?
 
 I'm in such a position now, and it's great. Mind you, as I said in
 another post in this thread, I have separated code and presentation
 for years and so I'm probably biased. ;) I can just think about code
 and let someone else handle the presentation. That doesn't mean that
 the weenies* don't have input into the code, or that I don't have
 input into the presentation, just that we don't have to focus on jobs
 that aren't ours.
 
 * - For the record, while I might have thought of the people doing the
 presentation as HTML weenies a few years ago, since then I've had to
 run a solo shop for a few years, have done layout for some CD
 releases, and so on--and I have gained respect for people with a truly
 good eye and the ability to translate that onto the screen. While I
 enjoy layout and presentation, it's not where my training is and I
 recognize superior talent when I see it. They have their strengths and
 I have mine and we do what we do best.
 

As for HTML weenies, my experience has been the opposite. My company
does websites, among other things. Most of my work involves our internal
website, which runs the company. I do PHP and the HTML for the internal
website. My wife does the design/HTML for customer websites. If a
customer website needs PHP, I do it. I don't know how many times we've 
had to deal with outside web design types, and found their work to be 
atrocious. I also have a fair amount of contempt for people who refuse
to learn anything outside their narrow field, which is what I see in a
lot of HTML folks. I would have more respect for them if they took the
time to understand at least something about PHP, and thus better
understand what I have to deal with in their HTML.

My wife doesn't know as much about HTML as I do, since she uses
Dreamweaver to code HTML. But I code HTML by hand, and I don't have the
patience to do fancy HTML the way she does. Consequently, the internal
website is visually pleasing but not fancy. Customer websites are
prettier than our internal one, but have almost no PHP in them.

However, I've had many situations where my wife has designed a pretty
page I have to now add PHP to. It's tricky. But as a consequence, I tend
to code HTML without resorting to rendering classes. Even though it
would be much easier to do it with classes.

Paul
-- 
Paul M. Foster

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



Re: [PHP] Couple of beginner questions

2009-01-12 Thread ceo

 are you really ever in a situation where some HTML weenie is coding

 HTML pages and you're somewhere else doing the PHP work?



Yes.



I have been there several times, and am there now.



In a well-run organization with good communication and a decent framework, it 
works out well.



Otherwise, it's quite bad, but probably not as bad as the total chaos of not 
trying to do it right at all.



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



Re: [PHP] Couple of beginner questions

2009-01-12 Thread Jason Pruim


On Jan 12, 2009, at 1:43 AM, Paul M Foster wrote:


On Mon, Jan 12, 2009 at 12:04:15AM -0500, John Corry wrote:


But here's a question for those of you who work in a collaborative
environment-- are you really ever in a situation where some HTML  
weenie
is coding HTML pages and you're somewhere else doing the PHP work?  
Or is

that some academic's view of the way things *should* be done?
I haven't been involved strictly in the way that you mention. BUT...  
I have done work where someone else designs the page, and I code the  
HTML/PHP/MySQL/Rocks(tm)(Learning dead languages is tough though :P)


Usually works quite well for me.



--
Jason Pruim
japr...@raoset.com
616.399.2355





Re: Re: [PHP] Couple of beginner questions

2009-01-12 Thread jcorry

On Jan 12, 2009 11:20am, Jason Pruim japr...@raoset.com wrote:



It's actually pretty normal and can work really well.

Especially if the HTML person also did the graphic design and KNOWS how to  
make it work as a web page.


We let them build HTML files, which are then turned into Smarty templates  
with the necessary blocks of Smarty code to work through whatever PHP hands  
to the template.


The PHP app developer can then focus on the application logic...with the  
app's output going to the appropriate Smarty template.


It's a pretty good system compared to the one person doing everything model  
that I worked under for a long time.


Even a one person team can use that approach by separating the tasks and  
then maintaining discipline to work on the separate tasks, separately.


John Corry



On Jan 12, 2009, at 1:43 AM, Paul M Foster wrote:




On Mon, Jan 12, 2009 at 12:04:15AM -0500, John Corry wrote:





But here's a question for those of you who work in a collaborative

environment-- are you really ever in a situation where some HTML weenie

is coding HTML pages and you're somewhere else doing the PHP work? Or is

that some academic's view of the way things *should* be done?




Re: [PHP] Couple of beginner questions

2009-01-12 Thread Frank Stanovcak

Ashley Sheridan  wrote in message 
news:1231681793.3527.2.ca...@localhost.localdomain...
 On Sun, 2009-01-11 at 08:08 -0500, tedd wrote:
 At 4:16 PM -0500 1/10/09, Paul M Foster wrote:
 And let me present an alternative perspective. Never do something like:
 
 ?php echo 'Hellow world'; ?
 
 Let Apache (or whatever) interpret HTML as HTML, and don't make it
 interpret PHP code as HTML.
 
 Instead, do:
 
 h1Hello world/h1
 
 If you're going to use PHP in the middle of a bunch of HTML, then only
 use it where it's needed:
 
 h1Hello ?php echo $name; ?/h1
 
 The contents of the PHP $name variable can't be seen by the HTML, which
 is why you need to enclose it in a little PHP island. Naturally, if
 you're going to put PHP code in the middle of a HTML page, make the
 extension PHP. Otherwise, Apache will not interpret the PHP code as PHP
 (unless you do some messing with .htaccess or whatever). It's just
 simplest to call a file something.php if it has PHP in it.
 
 Paul
 --
 Paul M. Foster

 Paul:

 I agree with you. My example was not well thought out. My point was
 not to mix style elements with data. I should have said:

 I would consider the followingbad practice:

   ?php echo(h1$whatever/h1); ?

 Whereas, the following I would consider good practice.

 h1?php echo($whatever); ?/h1

 Thanks for keeping me honest.

 Cheers,

 tedd


 -- 
 ---
 http://sperling.com  http://ancientstones.com  http://earthstones.com

 Unless it's something like this:

 ?php
 echo h1 class=\$headerClass\$whatever/h1;
 ?

 Which is unlikely for a header tag, but I know this sort of format gets
 used a lot by me and others, especially for setting alternate row styles
 on tables (damn browsers and not supporting alternate rows!)


 Ash
 www.ashleysheridan.co.uk


Hey Ash...Why don't you just use CSS subclassing?

style type=text/css
h1.odd {class stuff here}
h1.even {class stuff here}
/style

then

h1 class=odd?php echo $whatever; ?/h1

no escaping, and no need to php your css styles.  :)

Frank 



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



Re: [PHP] Couple of beginner questions

2009-01-12 Thread Ashley Sheridan
On Mon, 2009-01-12 at 11:20 -0500, Jason Pruim wrote:
 On Jan 12, 2009, at 1:43 AM, Paul M Foster wrote:
 
  On Mon, Jan 12, 2009 at 12:04:15AM -0500, John Corry wrote:
 
 
  But here's a question for those of you who work in a collaborative
  environment-- are you really ever in a situation where some HTML  
  weenie
  is coding HTML pages and you're somewhere else doing the PHP work?  
  Or is
  that some academic's view of the way things *should* be done?
 I haven't been involved strictly in the way that you mention. BUT...  
 I have done work where someone else designs the page, and I code the  
 HTML/PHP/MySQL/Rocks(tm)(Learning dead languages is tough though :P)
 
 Usually works quite well for me.
 
 
 
 --
 Jason Pruim
 japr...@raoset.com
 616.399.2355
 
 
 
I tend to work on projects on my own. I built the CMS that runs the
current website, and now building it's sibling to run all the company
sites under one roof. I just get given the design, then I go from there
doing all the HTML, Javascript, CSS, PHP and MySQL from there. I have
the advantage in that when I need to update the code, I know exactly how
I've done it, but I have the disadvantage in that I don't know if what
I'm doing is meeting a decent standard by other peoples opinion.

I do try more and more to logically separate function from form, and the
only time I deviate from that in the main is with heredocs, which I
don't count as a sin I'll be sent to hell for ;)


Ash
www.ashleysheridan.co.uk


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



Re: [PHP] Couple of beginner questions

2009-01-12 Thread Ashley Sheridan
On Mon, 2009-01-12 at 11:51 -0500, Frank Stanovcak wrote:
 Ashley Sheridan  wrote in message 
 news:1231681793.3527.2.ca...@localhost.localdomain...
  On Sun, 2009-01-11 at 08:08 -0500, tedd wrote:
  At 4:16 PM -0500 1/10/09, Paul M Foster wrote:
  And let me present an alternative perspective. Never do something like:
  
  ?php echo 'Hellow world'; ?
  
  Let Apache (or whatever) interpret HTML as HTML, and don't make it
  interpret PHP code as HTML.
  
  Instead, do:
  
  h1Hello world/h1
  
  If you're going to use PHP in the middle of a bunch of HTML, then only
  use it where it's needed:
  
  h1Hello ?php echo $name; ?/h1
  
  The contents of the PHP $name variable can't be seen by the HTML, which
  is why you need to enclose it in a little PHP island. Naturally, if
  you're going to put PHP code in the middle of a HTML page, make the
  extension PHP. Otherwise, Apache will not interpret the PHP code as PHP
  (unless you do some messing with .htaccess or whatever). It's just
  simplest to call a file something.php if it has PHP in it.
  
  Paul
  --
  Paul M. Foster
 
  Paul:
 
  I agree with you. My example was not well thought out. My point was
  not to mix style elements with data. I should have said:
 
  I would consider the followingbad practice:
 
?php echo(h1$whatever/h1); ?
 
  Whereas, the following I would consider good practice.
 
  h1?php echo($whatever); ?/h1
 
  Thanks for keeping me honest.
 
  Cheers,
 
  tedd
 
 
  -- 
  ---
  http://sperling.com  http://ancientstones.com  http://earthstones.com
 
  Unless it's something like this:
 
  ?php
  echo h1 class=\$headerClass\$whatever/h1;
  ?
 
  Which is unlikely for a header tag, but I know this sort of format gets
  used a lot by me and others, especially for setting alternate row styles
  on tables (damn browsers and not supporting alternate rows!)
 
 
  Ash
  www.ashleysheridan.co.uk
 
 
 Hey Ash...Why don't you just use CSS subclassing?
 
 style type=text/css
 h1.odd {class stuff here}
 h1.even {class stuff here}
 /style
 
 then
 
 h1 class=odd?php echo $whatever; ?/h1
 
 no escaping, and no need to php your css styles.  :)
 
 Frank 
 
 
 
That's what I do do, but the 'odd' has to come from PHP, as
unfortunately, numerical selectors in CSS aren't supported by (AFAIK)
any browsers at the moment. So for example, if I was coding for
alternate rows in a table, I might do:


for($i=0; $i$some_limit; $i++)
{
$rowClass = ($i % 2 == 0)?'':'class=alternate';
print EOP
tr $rowClass
td.../td
td.../td
td.../td
/tr
EOP;
}

As far as such loops go, is this a particular faux pas in regards to the
way it's coded? Go on Tedd ;)


Ash
www.ashleysheridan.co.uk


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



Re: [PHP] Couple of beginner questions

2009-01-12 Thread Nathan Rixham

Ashley Sheridan wrote:

On Mon, 2009-01-12 at 11:51 -0500, Frank Stanovcak wrote:
Ashley Sheridan  wrote in message 
news:1231681793.3527.2.ca...@localhost.localdomain...

On Sun, 2009-01-11 at 08:08 -0500, tedd wrote:

At 4:16 PM -0500 1/10/09, Paul M Foster wrote:

And let me present an alternative perspective. Never do something like:

?php echo 'Hellow world'; ?

Let Apache (or whatever) interpret HTML as HTML, and don't make it
interpret PHP code as HTML.

Instead, do:

h1Hello world/h1

If you're going to use PHP in the middle of a bunch of HTML, then only
use it where it's needed:

h1Hello ?php echo $name; ?/h1

The contents of the PHP $name variable can't be seen by the HTML, which
is why you need to enclose it in a little PHP island. Naturally, if
you're going to put PHP code in the middle of a HTML page, make the
extension PHP. Otherwise, Apache will not interpret the PHP code as PHP
(unless you do some messing with .htaccess or whatever). It's just
simplest to call a file something.php if it has PHP in it.

Paul
--
Paul M. Foster

Paul:

I agree with you. My example was not well thought out. My point was
not to mix style elements with data. I should have said:

I would consider the followingbad practice:

  ?php echo(h1$whatever/h1); ?

Whereas, the following I would consider good practice.

h1?php echo($whatever); ?/h1

Thanks for keeping me honest.

Cheers,

tedd


--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com


Unless it's something like this:

?php
echo h1 class=\$headerClass\$whatever/h1;
?

Which is unlikely for a header tag, but I know this sort of format gets
used a lot by me and others, especially for setting alternate row styles
on tables (damn browsers and not supporting alternate rows!)


Ash
www.ashleysheridan.co.uk


Hey Ash...Why don't you just use CSS subclassing?

style type=text/css
h1.odd {class stuff here}
h1.even {class stuff here}
/style

then

h1 class=odd?php echo $whatever; ?/h1

no escaping, and no need to php your css styles.  :)

Frank 





That's what I do do, but the 'odd' has to come from PHP, as
unfortunately, numerical selectors in CSS aren't supported by (AFAIK)
any browsers at the moment. So for example, if I was coding for
alternate rows in a table, I might do:


for($i=0; $i$some_limit; $i++)
{
$rowClass = ($i % 2 == 0)?'':'class=alternate';
print EOP
tr $rowClass
td.../td
td.../td
td.../td
/tr
EOP;
}

As far as such loops go, is this a particular faux pas in regards to the
way it's coded? Go on Tedd ;)


Ash
www.ashleysheridan.co.uk



nice pick-up on the fact you only need to css the alternate row not both 
odd and even :p


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



Re: [PHP] Couple of beginner questions

2009-01-12 Thread Ashley Sheridan
On Mon, 2009-01-12 at 19:43 +, Nathan Rixham wrote:
 Ashley Sheridan wrote:
  On Mon, 2009-01-12 at 11:51 -0500, Frank Stanovcak wrote:
  Ashley Sheridan  wrote in message 
  news:1231681793.3527.2.ca...@localhost.localdomain...
  On Sun, 2009-01-11 at 08:08 -0500, tedd wrote:
  At 4:16 PM -0500 1/10/09, Paul M Foster wrote:
  And let me present an alternative perspective. Never do something like:
 
  ?php echo 'Hellow world'; ?
 
  Let Apache (or whatever) interpret HTML as HTML, and don't make it
  interpret PHP code as HTML.
 
  Instead, do:
 
  h1Hello world/h1
 
  If you're going to use PHP in the middle of a bunch of HTML, then only
  use it where it's needed:
 
  h1Hello ?php echo $name; ?/h1
 
  The contents of the PHP $name variable can't be seen by the HTML, which
  is why you need to enclose it in a little PHP island. Naturally, if
  you're going to put PHP code in the middle of a HTML page, make the
  extension PHP. Otherwise, Apache will not interpret the PHP code as PHP
  (unless you do some messing with .htaccess or whatever). It's just
  simplest to call a file something.php if it has PHP in it.
 
  Paul
  --
  Paul M. Foster
  Paul:
 
  I agree with you. My example was not well thought out. My point was
  not to mix style elements with data. I should have said:
 
  I would consider the followingbad practice:
 
?php echo(h1$whatever/h1); ?
 
  Whereas, the following I would consider good practice.
 
  h1?php echo($whatever); ?/h1
 
  Thanks for keeping me honest.
 
  Cheers,
 
  tedd
 
 
  -- 
  ---
  http://sperling.com  http://ancientstones.com  http://earthstones.com
 
  Unless it's something like this:
 
  ?php
  echo h1 class=\$headerClass\$whatever/h1;
  ?
 
  Which is unlikely for a header tag, but I know this sort of format gets
  used a lot by me and others, especially for setting alternate row styles
  on tables (damn browsers and not supporting alternate rows!)
 
 
  Ash
  www.ashleysheridan.co.uk
 
  Hey Ash...Why don't you just use CSS subclassing?
 
  style type=text/css
  h1.odd {class stuff here}
  h1.even {class stuff here}
  /style
 
  then
 
  h1 class=odd?php echo $whatever; ?/h1
 
  no escaping, and no need to php your css styles.  :)
 
  Frank 
 
 
 
  That's what I do do, but the 'odd' has to come from PHP, as
  unfortunately, numerical selectors in CSS aren't supported by (AFAIK)
  any browsers at the moment. So for example, if I was coding for
  alternate rows in a table, I might do:
  
  
  for($i=0; $i$some_limit; $i++)
  {
  $rowClass = ($i % 2 == 0)?'':'class=alternate';
  print EOP
  tr $rowClass
  td.../td
  td.../td
  td.../td
  /tr
  EOP;
  }
  
  As far as such loops go, is this a particular faux pas in regards to the
  way it's coded? Go on Tedd ;)
  
  
  Ash
  www.ashleysheridan.co.uk
  
 
 nice pick-up on the fact you only need to css the alternate row not both 
 odd and even :p
 
Yeah, I think my laziness had something to do with that, I didn't want
to have to go and define another style ;)


Ash
www.ashleysheridan.co.uk


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



Re: [PHP] Couple of beginner questions

2009-01-12 Thread tedd

At 7:47 PM + 1/12/09, Ashley Sheridan wrote:

Ehat's what I do do, but the 'odd' has to come from PHP, as
unfortunately, numerical selectors in CSS aren't supported by (AFAIK)
any browsers at the moment. So for example, if I was coding for
alternate rows in a table, I might do:
for($i=0; $i$some_limit; $i++)
{
$rowClass = ($i % 2 == 0)?'':'class=alternate';
print EOP
tr $rowClass
td.../td
td.../td
td.../td
/tr
EOP;
}

As far as such loops go, is this a particular faux pas in regards to the
way it's coded? Go on Tedd ;)


Ash


True, css does not allow numeric classes (like sessions). But, I 
never need them anyway.


As I provided before:

http://webbytedd.com/b/color-rows/

this is my solution for alternating row style.

As for the above code being something I approve, or not -- I see your point.

Heredoc's do present a mixture of text (HTML, et all.) that begs the 
question of IF it is keeping html and php separate.


On one hand, some can say that a heredoc IS a component as much as 
echo() and thus should not contain html. But on the other hand, 
that's what it was designed for. So, it's one of those things that 
can't be judged in such fashion.


However, I can say that a heredoc containing html does not brother me 
as much as an echo() containing the same.


Cheers,

tedd

--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

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



Re: [PHP] Couple of beginner questions

2009-01-12 Thread Robert Cummings
On Mon, 2009-01-12 at 16:02 -0500, tedd wrote:

 True, css does not allow numeric classes (like sessions). But, I 
 never need them anyway.
 
 As I provided before:
 
 http://webbytedd.com/b/color-rows/
 
 this is my solution for alternating row style.

tr class=row?php echo($i++  1 );?
td abc/td
td abc/td
td abc/td
/tr

That's just wasteful... Here's better:

tr class=row?php echo( $i ^= 1 );?
td abc/td
td abc/td
td abc/td
/tr

Cheers,
Rob.
-- 
http://www.interjinn.com
Application and Templating Framework for PHP


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



Re: [PHP] Couple of beginner questions

2009-01-12 Thread Eric Butera
On Mon, Jan 12, 2009 at 4:17 PM, Robert Cummings rob...@interjinn.com wrote:
 On Mon, 2009-01-12 at 16:02 -0500, tedd wrote:

 True, css does not allow numeric classes (like sessions). But, I
 never need them anyway.

 As I provided before:

 http://webbytedd.com/b/color-rows/

 this is my solution for alternating row style.

 tr class=row?php echo($i++  1 );?
td abc/td
td abc/td
td abc/td
 /tr

 That's just wasteful... Here's better:

 tr class=row?php echo( $i ^= 1 );?
td abc/td
td abc/td
td abc/td
 /tr

 Cheers,
 Rob.
 --
 http://www.interjinn.com
 Application and Templating Framework for PHP


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



You guys with your clever bit-shifting.  :)

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



Re: [PHP] Couple of beginner questions

2009-01-12 Thread Ashley Sheridan
On Mon, 2009-01-12 at 16:17 -0500, Robert Cummings wrote:
 On Mon, 2009-01-12 at 16:02 -0500, tedd wrote:
 
  True, css does not allow numeric classes (like sessions). But, I 
  never need them anyway.
  
  As I provided before:
  
  http://webbytedd.com/b/color-rows/
  
  this is my solution for alternating row style.
 
 tr class=row?php echo($i++  1 );?
 td abc/td
 td abc/td
 td abc/td
 /tr
 
 That's just wasteful... Here's better:
 
 tr class=row?php echo( $i ^= 1 );?
 td abc/td
 td abc/td
 td abc/td
 /tr
 
 Cheers,
 Rob.
It is a *lot* smaller than my example. I like it! :p


Ash
www.ashleysheridan.co.uk


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



Re: [PHP] Couple of beginner questions

2009-01-12 Thread Nathan Rixham

Robert Cummings wrote:

On Mon, 2009-01-12 at 16:02 -0500, tedd wrote:
True, css does not allow numeric classes (like sessions). But, I 
never need them anyway.


As I provided before:

http://webbytedd.com/b/color-rows/

this is my solution for alternating row style.


tr class=row?php echo($i++  1 );?
td abc/td
td abc/td
td abc/td
/tr

That's just wasteful... Here's better:

tr class=row?php echo( $i ^= 1 );?
td abc/td
td abc/td
td abc/td
/tr

Cheers,
Rob.


wtf? that's some freaky bug right there rob..

?php
for($i=0;$i10;$i++) {
?
tr class=row?php echo( $i ^= 1 ); ?
td abc/td
td abc/td
td abc/td
/tr
?php
}
?

output:
tr class=row1
td abc/td
td abc/td
td abc/td
/tr
tr class=row3
td abc/td
td abc/td
td abc/td
/tr
tr class=row5
td abc/td
td abc/td
td abc/td
/tr
tr class=row7
td abc/td
td abc/td
td abc/td
/tr
tr class=row9
td abc/td
td abc/td
td abc/td
/tr

php 5.2.5 - weird

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



Re: [PHP] Couple of beginner questions

2009-01-12 Thread Robert Cummings
On Mon, 2009-01-12 at 16:26 -0500, Eric Butera wrote:
 On Mon, Jan 12, 2009 at 4:17 PM, Robert Cummings 
 
  tr class=row?php echo( $i ^= 1 );?
 td abc/td
 td abc/td
 td abc/td
  /tr
 
  Cheers,
  Rob.
  --
  http://www.interjinn.com
  Application and Templating Framework for PHP
 
 
  --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 
 
 
 You guys with your clever bit-shifting.  :)

That was a toggle, not a shift :D

Cheers,
Rob.
-- 
http://www.interjinn.com
Application and Templating Framework for PHP


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



Re: [PHP] Couple of beginner questions

2009-01-12 Thread Robert Cummings
On Mon, 2009-01-12 at 21:36 +, Nathan Rixham wrote:
 Robert Cummings wrote:
  On Mon, 2009-01-12 at 16:02 -0500, tedd wrote:
  True, css does not allow numeric classes (like sessions). But, I 
  never need them anyway.
 
  As I provided before:
 
  http://webbytedd.com/b/color-rows/
 
  this is my solution for alternating row style.
  
  tr class=row?php echo($i++  1 );?
  td abc/td
  td abc/td
  td abc/td
  /tr
  
  That's just wasteful... Here's better:
  
  tr class=row?php echo( $i ^= 1 );?
  td abc/td
  td abc/td
  td abc/td
  /tr
  
  Cheers,
  Rob.
 
 wtf? that's some freaky bug right there rob..
 
 ?php
 for($i=0;$i10;$i++) {
 ?
 tr class=row?php echo( $i ^= 1 ); ?
  td abc/td
  td abc/td
  td abc/td
 /tr
 ?php
 }
 ?
 
 output:
 tr class=row1
  td abc/td
  td abc/td
  td abc/td
 /tr
 tr class=row3
  td abc/td
  td abc/td
  td abc/td
 /tr
 tr class=row5
  td abc/td
  td abc/td
  td abc/td
 /tr
 tr class=row7
  td abc/td
  td abc/td
  td abc/td
 /tr
 tr class=row9
  td abc/td
  td abc/td
  td abc/td
 /tr
 
 php 5.2.5 - weird

Nooo... you introduced the bug, my code presumed a foreach loop and
$i intialized to 0. You're code doesn't work with tedd's version either
since you're incrementing $i in the loop and in the HTML output... thus
it will always be even.

Cheers,
Rob.
-- 
http://www.interjinn.com
Application and Templating Framework for PHP


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



Re: [PHP] Couple of beginner questions

2009-01-12 Thread Nathan Rixham

Robert Cummings wrote:

On Mon, 2009-01-12 at 21:36 +, Nathan Rixham wrote:
  

Robert Cummings wrote:


On Mon, 2009-01-12 at 16:02 -0500, tedd wrote:
  
True, css does not allow numeric classes (like sessions). But, I 
never need them anyway.


As I provided before:

http://webbytedd.com/b/color-rows/

this is my solution for alternating row style.


tr class=row?php echo($i++  1 );?
td abc/td
td abc/td
td abc/td
/tr

That's just wasteful... Here's better:

tr class=row?php echo( $i ^= 1 );?
td abc/td
td abc/td
td abc/td
/tr

Cheers,
Rob.
  

wtf? that's some freaky bug right there rob..

?php
for($i=0;$i10;$i++) {
?
tr class=row?php echo( $i ^= 1 ); ?
 td abc/td
 td abc/td
 td abc/td
/tr
?php
}
?

output:
tr class=row1
 td abc/td
 td abc/td
 td abc/td
/tr
tr class=row3
 td abc/td
 td abc/td
 td abc/td
/tr
tr class=row5
 td abc/td
 td abc/td
 td abc/td
/tr
tr class=row7
 td abc/td
 td abc/td
 td abc/td
/tr
tr class=row9
 td abc/td
 td abc/td
 td abc/td
/tr

php 5.2.5 - weird



Nooo... you introduced the bug, my code presumed a foreach loop and
$i intialized to 0. You're code doesn't work with tedd's version either
since you're incrementing $i in the loop and in the HTML output... thus
it will always be even.

Cheers,
Rob.
  

but the rest should echo regardless..?

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



Re: [PHP] Couple of beginner questions

2009-01-12 Thread Robert Cummings
On Mon, 2009-01-12 at 21:45 +, Nathan Rixham wrote:
 Robert Cummings wrote:
  On Mon, 2009-01-12 at 21:36 +, Nathan Rixham wrote:

  Robert Cummings wrote:
  
  On Mon, 2009-01-12 at 16:02 -0500, tedd wrote:

  True, css does not allow numeric classes (like sessions). But, I 
  never need them anyway.
 
  As I provided before:
 
  http://webbytedd.com/b/color-rows/
 
  this is my solution for alternating row style.
  
  tr class=row?php echo($i++  1 );?
  td abc/td
  td abc/td
  td abc/td
  /tr
 
  That's just wasteful... Here's better:
 
  tr class=row?php echo( $i ^= 1 );?
  td abc/td
  td abc/td
  td abc/td
  /tr
 
  Cheers,
  Rob.

  wtf? that's some freaky bug right there rob..
 
  ?php
  for($i=0;$i10;$i++) {
  ?
  tr class=row?php echo( $i ^= 1 ); ?
   td abc/td
   td abc/td
   td abc/td
  /tr
  ?php
  }
  ?
 
  output:
  tr class=row1
   td abc/td
   td abc/td
   td abc/td
  /tr
  tr class=row3
   td abc/td
   td abc/td
   td abc/td
  /tr
  tr class=row5
   td abc/td
   td abc/td
   td abc/td
  /tr
  tr class=row7
   td abc/td
   td abc/td
   td abc/td
  /tr
  tr class=row9
   td abc/td
   td abc/td
   td abc/td
  /tr
 
  php 5.2.5 - weird
  
 
  Nooo... you introduced the bug, my code presumed a foreach loop and
  $i intialized to 0. You're code doesn't work with tedd's version either
  since you're incrementing $i in the loop and in the HTML output... thus
  it will always be even.
 
  Cheers,
  Rob.

 but the rest should echo regardless..?

Huh?

-- 
http://www.interjinn.com
Application and Templating Framework for PHP


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



Re: [PHP] Couple of beginner questions

2009-01-12 Thread Nathan Rixham

Nathan Rixham wrote:

Robert Cummings wrote:

On Mon, 2009-01-12 at 21:36 +, Nathan Rixham wrote:
 

Robert Cummings wrote:
   

On Mon, 2009-01-12 at 16:02 -0500, tedd wrote:
 
True, css does not allow numeric classes (like sessions). But, I 
never need them anyway.


As I provided before:

http://webbytedd.com/b/color-rows/

this is my solution for alternating row style.


tr class=row?php echo($i++  1 );?
td abc/td
td abc/td
td abc/td
/tr

That's just wasteful... Here's better:

tr class=row?php echo( $i ^= 1 );?
td abc/td
td abc/td
td abc/td
/tr

Cheers,
Rob.
  

wtf? that's some freaky bug right there rob..

?php
for($i=0;$i10;$i++) {
?
tr class=row?php echo( $i ^= 1 ); ?
 td abc/td
 td abc/td
 td abc/td
/tr
?php
}
?

output:
tr class=row1
 td abc/td
 td abc/td
 td abc/td
/tr
tr class=row3
 td abc/td
 td abc/td
 td abc/td
/tr
tr class=row5
 td abc/td
 td abc/td
 td abc/td
/tr
tr class=row7
 td abc/td
 td abc/td
 td abc/td
/tr
tr class=row9
 td abc/td
 td abc/td
 td abc/td
/tr

php 5.2.5 - weird



Nooo... you introduced the bug, my code presumed a foreach loop and
$i intialized to 0. You're code doesn't work with tedd's version either
since you're incrementing $i in the loop and in the HTML output... thus
it will always be even.

Cheers,
Rob.
  

but the rest should echo regardless..?


doh scratch that

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



Re: [PHP] Couple of beginner questions

2009-01-12 Thread tedd

At 4:17 PM -0500 1/12/09, Robert Cummings wrote:

On Mon, 2009-01-12 at 16:02 -0500, tedd wrote:


 True, css does not allow numeric classes (like sessions). But, I
 never need them anyway.

 As I provided before:

 http://webbytedd.com/b/color-rows/

 this is my solution for alternating row style.


tr class=row?php echo($i++  1 );?
td abc/td
td abc/td
td abc/td
/tr

That's just wasteful... Here's better:

tr class=row?php echo( $i ^= 1 );?
td abc/td
td abc/td
td abc/td
/tr

Cheers,
Rob.



I like waste. :-)

tedd



--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

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



Re: [PHP] Couple of beginner questions

2009-01-12 Thread tedd

At 9:37 PM + 1/12/09, Ashley Sheridan wrote:

On Mon, 2009-01-12 at 16:17 -0500, Robert Cummings wrote:

 On Mon, 2009-01-12 at 16:02 -0500, tedd wrote:
 
  True, css does not allow numeric classes (like sessions). But, I
  never need them anyway.
 
  As I provided before:
 
  http://webbytedd.com/b/color-rows/
 
  this is my solution for alternating row style.

 tr class=row?php echo($i++  1 );?
 td abc/td
 td abc/td
 td abc/td
 /tr

 That's just wasteful... Here's better:

 tr class=row?php echo( $i ^= 1 );?
 td abc/td
 td abc/td
 td abc/td
 /tr

 Cheers,
 Rob.

It is a *lot* smaller than my example. I like it! :p


Rob is good at providing small examples, but maybe we shouldn't talk 
about that. :-)


Cheers,

tedd

--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

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



Re: [PHP] Couple of beginner questions

2009-01-12 Thread Ashley Sheridan
On Mon, 2009-01-12 at 16:54 -0500, tedd wrote:
 At 9:37 PM + 1/12/09, Ashley Sheridan wrote:
 On Mon, 2009-01-12 at 16:17 -0500, Robert Cummings wrote:
   On Mon, 2009-01-12 at 16:02 -0500, tedd wrote:
   
True, css does not allow numeric classes (like sessions). But, I
never need them anyway.
   
As I provided before:
   
http://webbytedd.com/b/color-rows/
   
this is my solution for alternating row style.
 
   tr class=row?php echo($i++  1 );?
   td abc/td
   td abc/td
   td abc/td
   /tr
 
   That's just wasteful... Here's better:
 
   tr class=row?php echo( $i ^= 1 );?
   td abc/td
   td abc/td
   td abc/td
   /tr
 
   Cheers,
   Rob.
 It is a *lot* smaller than my example. I like it! :p
 
 Rob is good at providing small examples, but maybe we shouldn't talk 
 about that. :-)
 
 Cheers,
 
 tedd
 
Lol, are we still talking about PHP here? ;)


Ash
www.ashleysheridan.co.uk


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



Re: [PHP] Couple of beginner questions

2009-01-12 Thread Robert Cummings
On Mon, 2009-01-12 at 16:51 -0500, tedd wrote:
 At 4:17 PM -0500 1/12/09, Robert Cummings wrote:
 On Mon, 2009-01-12 at 16:02 -0500, tedd wrote:
 
   True, css does not allow numeric classes (like sessions). But, I
   never need them anyway.
 
   As I provided before:
 
   http://webbytedd.com/b/color-rows/
 
   this is my solution for alternating row style.
 
 tr class=row?php echo($i++  1 );?
  td abc/td
  td abc/td
  td abc/td
 /tr
 
 That's just wasteful... Here's better:
 
 tr class=row?php echo( $i ^= 1 );?
  td abc/td
  td abc/td
  td abc/td
 /tr
 
 Cheers,
 Rob.
 
 
 I like waste. :-)

My 3 month old son likes to make waste... I could send you some uh
samples.

Cheers,
Rob.
-- 
http://www.interjinn.com
Application and Templating Framework for PHP


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



Re: [PHP] Couple of beginner questions

2009-01-12 Thread Robert Cummings
On Mon, 2009-01-12 at 16:54 -0500, tedd wrote:
 At 9:37 PM + 1/12/09, Ashley Sheridan wrote:
 On Mon, 2009-01-12 at 16:17 -0500, Robert Cummings wrote:
   On Mon, 2009-01-12 at 16:02 -0500, tedd wrote:
   
True, css does not allow numeric classes (like sessions). But, I
never need them anyway.
   
As I provided before:
   
http://webbytedd.com/b/color-rows/
   
this is my solution for alternating row style.
 
   tr class=row?php echo($i++  1 );?
   td abc/td
   td abc/td
   td abc/td
   /tr
 
   That's just wasteful... Here's better:
 
   tr class=row?php echo( $i ^= 1 );?
   td abc/td
   td abc/td
   td abc/td
   /tr
 
   Cheers,
   Rob.
 It is a *lot* smaller than my example. I like it! :p
 
 Rob is good at providing small examples, but maybe we shouldn't talk 
 about that. :-)

It's not the size of the example, it's the efficacy of the example that
matters :D

Cheers,
Rob.
-- 
http://www.interjinn.com
Application and Templating Framework for PHP


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



Re: [PHP] Couple of beginner questions

2009-01-11 Thread tedd

At 4:16 PM -0500 1/10/09, Paul M Foster wrote:

And let me present an alternative perspective. Never do something like:

?php echo 'Hellow world'; ?

Let Apache (or whatever) interpret HTML as HTML, and don't make it
interpret PHP code as HTML.

Instead, do:

h1Hello world/h1

If you're going to use PHP in the middle of a bunch of HTML, then only
use it where it's needed:

h1Hello ?php echo $name; ?/h1

The contents of the PHP $name variable can't be seen by the HTML, which
is why you need to enclose it in a little PHP island. Naturally, if
you're going to put PHP code in the middle of a HTML page, make the
extension PHP. Otherwise, Apache will not interpret the PHP code as PHP
(unless you do some messing with .htaccess or whatever). It's just
simplest to call a file something.php if it has PHP in it.

Paul
--
Paul M. Foster


Paul:

I agree with you. My example was not well thought out. My point was 
not to mix style elements with data. I should have said:


I would consider the followingbad practice:

 ?php echo(h1$whatever/h1); ?

Whereas, the following I would consider good practice.

h1?php echo($whatever); ?/h1

Thanks for keeping me honest.

Cheers,

tedd


--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

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



Re: [PHP] Couple of beginner questions

2009-01-11 Thread Ashley Sheridan
On Sun, 2009-01-11 at 08:08 -0500, tedd wrote:
 At 4:16 PM -0500 1/10/09, Paul M Foster wrote:
 And let me present an alternative perspective. Never do something like:
 
 ?php echo 'Hellow world'; ?
 
 Let Apache (or whatever) interpret HTML as HTML, and don't make it
 interpret PHP code as HTML.
 
 Instead, do:
 
 h1Hello world/h1
 
 If you're going to use PHP in the middle of a bunch of HTML, then only
 use it where it's needed:
 
 h1Hello ?php echo $name; ?/h1
 
 The contents of the PHP $name variable can't be seen by the HTML, which
 is why you need to enclose it in a little PHP island. Naturally, if
 you're going to put PHP code in the middle of a HTML page, make the
 extension PHP. Otherwise, Apache will not interpret the PHP code as PHP
 (unless you do some messing with .htaccess or whatever). It's just
 simplest to call a file something.php if it has PHP in it.
 
 Paul
 --
 Paul M. Foster
 
 Paul:
 
 I agree with you. My example was not well thought out. My point was 
 not to mix style elements with data. I should have said:
 
 I would consider the followingbad practice:
 
   ?php echo(h1$whatever/h1); ?
 
 Whereas, the following I would consider good practice.
 
 h1?php echo($whatever); ?/h1
 
 Thanks for keeping me honest.
 
 Cheers,
 
 tedd
 
 
 -- 
 ---
 http://sperling.com  http://ancientstones.com  http://earthstones.com
 
Unless it's something like this:

?php
echo h1 class=\$headerClass\$whatever/h1;
?

Which is unlikely for a header tag, but I know this sort of format gets
used a lot by me and others, especially for setting alternate row styles
on tables (damn browsers and not supporting alternate rows!)


Ash
www.ashleysheridan.co.uk


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



Re: [PHP] Couple of beginner questions

2009-01-11 Thread tedd

At 1:49 PM + 1/11/09, Ashley Sheridan wrote:


Unless it's something like this:

?php
echo h1 class=\$headerClass\$whatever/h1;
?

Which is unlikely for a header tag, but I know this sort of format gets
used a lot by me and others, especially for setting alternate row styles
on tables (damn browsers and not supporting alternate rows!)

Ash


Ash:

Here's the alterative I would use:

h1 class=php echo($headerClass);?php echo($whatever);?/h1

Again, please forgive my use of echo().

The point being, wherever you want to insert a variable, then do it, 
but leave html out of your code.


My alternate row styles solution is this:

http://webbytedd.com/b/color-rows/

Please note that no html is harmed in the making of this presentation. :-)

Cheers,

tedd

--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

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



Re: [PHP] Couple of beginner questions

2009-01-11 Thread Ashley Sheridan
On Sun, 2009-01-11 at 09:46 -0500, tedd wrote:
 At 1:49 PM + 1/11/09, Ashley Sheridan wrote:
 
 Unless it's something like this:
 
 ?php
 echo h1 class=\$headerClass\$whatever/h1;
 ?
 
 Which is unlikely for a header tag, but I know this sort of format gets
 used a lot by me and others, especially for setting alternate row styles
 on tables (damn browsers and not supporting alternate rows!)
 
 Ash
 
 Ash:
 
 Here's the alterative I would use:
 
 h1 class=php echo($headerClass);?php echo($whatever);?/h1
 
 Again, please forgive my use of echo().
 
 The point being, wherever you want to insert a variable, then do it, 
 but leave html out of your code.
 
 My alternate row styles solution is this:
 
 http://webbytedd.com/b/color-rows/
 
 Please note that no html is harmed in the making of this presentation. :-)
 
 Cheers,
 
 tedd
 
I'm not wanting ti nitpick, but what if there were several attributes
you needed to populate from the PHP? I just find it easier on my eyes to
include HTML in the PHP string that's being output, but I can see the
definite merits for echoing out single parts that would only get in the
way of the HTML.


Ash
www.ashleysheridan.co.uk


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



Re: [PHP] Couple of beginner questions

2009-01-11 Thread tedd

At 3:02 PM + 1/11/09, Ashley Sheridan wrote:

On Sun, 2009-01-11 at 09:46 -0500, tedd wrote:

 At 1:49 PM + 1/11/09, Ashley Sheridan wrote:

  

 Unless it's something like this:
 
 ?php
 echo h1 class=\$headerClass\$whatever/h1;

  ?
 

 Here's the alterative I would use:


  h1 class=php echo($headerClass);?php echo($whatever);?/h1

I'm not wanting ti nitpick, but what if there were several attributes
you needed to populate from the PHP? I just find it easier on my eyes to
include HTML in the PHP string that's being output, but I can see the
definite merits for echoing out single parts that would only get in the
way of the HTML.


Ash:

Nitpick as much as you want -- we all have our level of accommodation.

To me, there usually is a clear demarcation between the different 
languages, their scope, and best application. If I had to deal with 
several attributes, such as shown here:


h1 class=red headerHello World/h1

I would write it up like so:

$header_class = red header;
$whatever = Hello World;

h1 class=php echo($header_class);?php echo($whatever);?/h1

In my css, I would have

.red
   {
   color: #ff;
   }

.header
   {
   font-size: 1.2em;
   }

That would solve the problem of several attributes and keep php, 
html, and css separate.


So handling numerous attributes would not be a problem for me.

Cheers,

tedd

--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

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



Re: [PHP] Couple of beginner questions

2009-01-11 Thread Ashley Sheridan
On Sun, 2009-01-11 at 10:16 -0500, tedd wrote:
 At 3:02 PM + 1/11/09, Ashley Sheridan wrote:
 On Sun, 2009-01-11 at 09:46 -0500, tedd wrote:
   At 1:49 PM + 1/11/09, Ashley Sheridan wrote:

   Unless it's something like this:
   
   ?php
   echo h1 class=\$headerClass\$whatever/h1;
?
   
   Here's the alterative I would use:
 
h1 class=php echo($headerClass);?php echo($whatever);?/h1
 
 I'm not wanting ti nitpick, but what if there were several attributes
 you needed to populate from the PHP? I just find it easier on my eyes to
 include HTML in the PHP string that's being output, but I can see the
 definite merits for echoing out single parts that would only get in the
 way of the HTML.
 
 Ash:
 
 Nitpick as much as you want -- we all have our level of accommodation.
 
 To me, there usually is a clear demarcation between the different 
 languages, their scope, and best application. If I had to deal with 
 several attributes, such as shown here:
 
 h1 class=red headerHello World/h1
 
 I would write it up like so:
 
 $header_class = red header;
 $whatever = Hello World;
 
 h1 class=php echo($header_class);?php echo($whatever);?/h1
 
 In my css, I would have
 
 .red
 {
 color: #ff;
 }
 
 .header
 {
 font-size: 1.2em;
 }
 
 That would solve the problem of several attributes and keep php, 
 html, and css separate.
 
 So handling numerous attributes would not be a problem for me.
 
 Cheers,
 
 tedd
 
 -- 
 ---
 http://sperling.com  http://ancientstones.com  http://earthstones.com
 
I was thinking more along the lines of this:

echo img src=\$url\ alt=\$alt\ title=\$alt\ class=\$imgclass
\/;


which looks like this otherwise:

img src=?php echo($url);? alt=?php echo($alt);? title=?php
echo($alt);? class=?php echo($imgclass);?/




Ash
www.ashleysheridan.co.uk


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



Re: [PHP] Couple of beginner questions

2009-01-11 Thread Eric Butera
On Sun, Jan 11, 2009 at 10:36 AM, Ashley Sheridan
a...@ashleysheridan.co.uk wrote:
 echo img src=\$url\ alt=\$alt\ title=\$alt\ class=\$imgclass

Gross!  If that is what you're doing use a printf or change attr
quotes to '.  I've seen entire html pages escaped out like that.

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



Re: [PHP] Couple of beginner questions

2009-01-11 Thread Ashley Sheridan
On Sun, 2009-01-11 at 10:44 -0500, Eric Butera wrote:
 On Sun, Jan 11, 2009 at 10:36 AM, Ashley Sheridan
 a...@ashleysheridan.co.uk wrote:
  echo img src=\$url\ alt=\$alt\ title=\$alt\ class=\$imgclass
 
 Gross!  If that is what you're doing use a printf or change attr
 quotes to '.  I've seen entire html pages escaped out like that.
 
No it was just an example, normally in that situation I use heredoc, but
I felt it unfair to deviate from the example I'd previously been using
as a comparison to the code separation method.


Ash
www.ashleysheridan.co.uk


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



Re: [PHP] Couple of beginner questions

2009-01-11 Thread Nathan Rixham

Ashley Sheridan wrote:

On Sun, 2009-01-11 at 10:16 -0500, tedd wrote:

At 3:02 PM + 1/11/09, Ashley Sheridan wrote:

On Sun, 2009-01-11 at 09:46 -0500, tedd wrote:

 At 1:49 PM + 1/11/09, Ashley Sheridan wrote:

  

 Unless it's something like this:
 
 ?php
 echo h1 class=\$headerClass\$whatever/h1;

  ?
 

 Here's the alterative I would use:


  h1 class=php echo($headerClass);?php echo($whatever);?/h1

I'm not wanting ti nitpick, but what if there were several attributes
you needed to populate from the PHP? I just find it easier on my eyes to
include HTML in the PHP string that's being output, but I can see the
definite merits for echoing out single parts that would only get in the
way of the HTML.

Ash:

Nitpick as much as you want -- we all have our level of accommodation.

To me, there usually is a clear demarcation between the different 
languages, their scope, and best application. If I had to deal with 
several attributes, such as shown here:


h1 class=red headerHello World/h1

I would write it up like so:

$header_class = red header;
$whatever = Hello World;

h1 class=php echo($header_class);?php echo($whatever);?/h1

In my css, I would have

.red
{
color: #ff;
}

.header
{
font-size: 1.2em;
}

That would solve the problem of several attributes and keep php, 
html, and css separate.


So handling numerous attributes would not be a problem for me.

Cheers,

tedd

--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com


I was thinking more along the lines of this:

echo img src=\$url\ alt=\$alt\ title=\$alt\ class=\$imgclass
\/;


which looks like this otherwise:

img src=?php echo($url);? alt=?php echo($alt);? title=?php
echo($alt);? class=?php echo($imgclass);?/




Ash
www.ashleysheridan.co.uk



i love these discussions on pedantics and semantics!

personally (when I need to) I always go for a bit of concatenation so in 
the example above:


// somewhere in the business logic / functional layer
$imgHTML = 'img src=' . $url . ' alt=' . $alt . ' title=' . $alt . 
' class=' . $imgclass . ' /';


.
// somewhere in the display layer
echo $imgHTML;

however; I only really do this when developing or in a quick bit of 
script; whenever possible I'll always use a templating engine, or 
xml/xsl which is the perfect abstraction between data and presentation IMHO.


another little note is that I'd never echo out a class or presentation 
data; infact I'd never use a class on a tag such as img either, 
preference going to a bit of css using selectors


div#article_content p img {
/* whatever */
}

I'm not sure what's brought me to these conclusions, I've certainly been 
through all the other methods of doing it - however for a couple of 
years now I've limitted all presentation to css only, css contained in a 
stylesheet - I try to use minimal css classes, and stick to using an id 
wherever I can't simply redefine the html tag.


TBH i think even if I'm doing a complete site myself, I still like to 
wear different caps (developer, designer, etc) and as such keep the 
layers as seperate as possible, as if it was somebody completely 
different working on the design.


the above means that moving back to the original h1 example(s) I'd simply

h1whatever/h1

css:
h1 {
  color: rgb(255,0,0);
  font-size: 1.2em;
}

seeing as you can only have one h1 tag on a single document.

if you can take any points from this ramble of mine, it'd be that IMHO 
the output from a script should at most comprise of something like:

?php
// business logic
$display_engine-output( $template , $variables );
?
infact ideally an html tag should never be seen in a php script

... and to take it further a echo'd string probably shouldn't either! so 
technically this is bad:


?php
if( whatever() ) {
// whatever
} else {
echo 'turns out you entered some invalid data client';
}
?

while this is good
?php
if( whatever() ) {
// whatever
} else {
throw new UnexpectedValueException( WHATEVER_ERROR_CODE );
}
?

which is caught higher up, the localized error message for 
WHATEVER_ERROR_CODE is then loaded, fired through to the display engine 
which formats and displays it to the client.


can seem like overkill, but if you want to have multiple front ends to 
you're app (say a soap interface, a flash ui and an html ui) there's no 
other way.


joy

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



Re: [PHP] Couple of beginner questions

2009-01-11 Thread Robert Cummings
On Sun, 2009-01-11 at 17:01 +, Nathan Rixham wrote:
 
 i love these discussions on pedantics and semantics!
 
 personally (when I need to) I always go for a bit of concatenation so in 
 the example above:
 
 // somewhere in the business logic / functional layer
 $imgHTML = 'img src=' . $url . ' alt=' . $alt . ' title=' . $alt . 
 ' class=' . $imgclass . ' /';

I do the same, except why you have all those space around your
concatenation I don't know. Although, to be honest I tend to vertically
spread my tags/attributes:

$imgHTML =
'img'
   .' src='.$url.''
   .' alt='.$alt.''
   .' title='.$alt.''
   .' class='.$imgclass.''
   .' /';

This makes it easy to see at a glance what is there and to also comment
out lines easily.

 .
 // somewhere in the display layer
 echo $imgHTML;

For images I usually do:

jinn:image src=//path/to/image/

The custom tag will expand the path to wherever the images directory was
defined and will scan the image for width and height and add those
attributes also.

 however; I only really do this when developing or in a quick bit of 
 script; whenever possible I'll always use a templating engine, or 
 xml/xsl which is the perfect abstraction between data and presentation IMHO.
 
 another little note is that I'd never echo out a class or presentation 
 data; infact I'd never use a class on a tag such as img either, 
 preference going to a bit of css using selectors
 
 div#article_content p img {
 /* whatever */
 }

Personally, I try not to use IDs to target my stylesheets. I try to use
IDs to target actual objects within the document for use with DHTML or
forms processing. It's a pain in the ass overriding a CSS rule that was
targeted with an ID since the ID carries so much weight. Otherwise, I
generally use higher up class definitions and do as you have done by
drilling down to individual members of the rule.

 I'm not sure what's brought me to these conclusions, I've certainly been 
 through all the other methods of doing it - however for a couple of 
 years now I've limitted all presentation to css only, css contained in a 
 stylesheet - I try to use minimal css classes, and stick to using an id 
 wherever I can't simply redefine the html tag.

I use lots and lots of CSS classes, all nicely kept in their own
contextual template files that are then built into the grand stylesheet
file with all my internal comments stripped from production.

 TBH i think even if I'm doing a complete site myself, I still like to 
 wear different caps (developer, designer, etc) and as such keep the 
 layers as seperate as possible, as if it was somebody completely 
 different working on the design.

Absolutely.

 the above means that moving back to the original h1 example(s) I'd simply
 
 h1whatever/h1

I'd probably do:

project:titleWhatever/project:title

Which would expand to:

h1 class=mainTitleWhateverjinn:accFlush
name=contentTitle/jinn:accFlush name=contentTitle
dyanmic=true//h1

Which would expand to a bunch of intermixed HTML/PHP code directly in
the requested document.

The reason for the accumulator flush is to add content to the title in
an unrelated area of the templates as is occasionally necessary. The
first inserts accumulated content during the build process, the second
allows insertion at run-time. Run-time is probably used more often since
it may be when editing a user profile or something and the name is
inserted into the title from the form controller. The compile time
version is used less often but has no run-time hit since it's pre-built.

 css:
 h1 {
color: rgb(255,0,0);
font-size: 1.2em;
 }
 
 seeing as you can only have one h1 tag on a single document.

Says who?

 if you can take any points from this ramble of mine, it'd be that IMHO 
 the output from a script should at most comprise of something like:
 ?php
 // business logic
 $display_engine-output( $template , $variables );
 ?
 infact ideally an html tag should never be seen in a php script

That depends on what the role of the PHP script is. A custom tag handler
certainly should output HTML. A forms engine certainly should hide the
HTML details unless you want to do all the low level form crap yourself
(mine outputs convenient CSS classes/ids transparently for me).

 ... and to take it further a echo'd string probably shouldn't either! so 
 technically this is bad:

Again that depends on the purpose of the echo'd string. And also whether
you just use PHP for web applications, or as I and many others do, also
use it for shell scripts.

 
 ?php
 if( whatever() ) {
 // whatever
 } else {
 echo 'turns out you entered some invalid data client';
 }
 ?
 
 while this is good
 ?php
 if( whatever() ) {
 // whatever
 } else {
 throw new UnexpectedValueException( WHATEVER_ERROR_CODE );
 }
 ?
 
 which is caught higher up, the localized error message for 
 WHATEVER_ERROR_CODE is then loaded, fired through to the display engine 
 which formats and displays it to the client.

Via echo? Thought you 

Re: [PHP] Couple of beginner questions

2009-01-11 Thread Nathan Rixham

Robert Cummings wrote:

On Sun, 2009-01-11 at 17:01 +, Nathan Rixham wrote:
  

i love these discussions on pedantics and semantics!

personally (when I need to) I always go for a bit of concatenation so in 
the example above:


// somewhere in the business logic / functional layer
$imgHTML = 'img src=' . $url . ' alt=' . $alt . ' title=' . $alt . 
' class=' . $imgclass . ' /';



I do the same, except why you have all those space around your
concatenation I don't know. Although, to be honest I tend to vertically
spread my tags/attributes:
  


re: space around concatenation; I add spaces in wherever I can, find it 
easier to read the code; and when it's a particularly long string it 
makes it far more readable; so using my own false logic if it's easier 
to see long, it's easier to see short as well.


re: vertically spread; I often do the same thing, general rule of thumb 
is if it's anywhere near a full line or scrolling sideways I'll 
multi-line it - in this case I would have multi-lined in my own code 
aswell :)



$imgHTML =
'img'
   .' src='.$url.''
   .' alt='.$alt.''
   .' title='.$alt.''
   .' class='.$imgclass.''
   .' /';

This makes it easy to see at a glance what is there and to also comment
out lines easily.

  

.
// somewhere in the display layer
echo $imgHTML;



For images I usually do:

jinn:image src=//path/to/image/

The custom tag will expand the path to wherever the images directory was
defined and will scan the image for width and height and add those
attributes also.

  
however; I only really do this when developing or in a quick bit of 
script; whenever possible I'll always use a templating engine, or 
xml/xsl which is the perfect abstraction between data and presentation IMHO.


another little note is that I'd never echo out a class or presentation 
data; infact I'd never use a class on a tag such as img either, 
preference going to a bit of css using selectors


div#article_content p img {
/* whatever */
}



Personally, I try not to use IDs to target my stylesheets. I try to use
IDs to target actual objects within the document for use with DHTML or
forms processing. It's a pain in the ass overriding a CSS rule that was
targeted with an ID since the ID carries so much weight. Otherwise, I
generally use higher up class definitions and do as you have done by
drilling down to individual members of the rule.
  
I use it for both; but sparingly for example div id=primary_nav 
means I should be able to pick up all sub elements for both dom 
manipulation and css rules
  
I'm not sure what's brought me to these conclusions, I've certainly been 
through all the other methods of doing it - however for a couple of 
years now I've limitted all presentation to css only, css contained in a 
stylesheet - I try to use minimal css classes, and stick to using an id 
wherever I can't simply redefine the html tag.



I use lots and lots of CSS classes, all nicely kept in their own
contextual template files that are then built into the grand stylesheet
file with all my internal comments stripped from production.
  


only time I'll use lots of classes is for things css like red, 
top-padding, bold etc (generics) never for .leftPageImageFirstImage
  
TBH i think even if I'm doing a complete site myself, I still like to 
wear different caps (developer, designer, etc) and as such keep the 
layers as seperate as possible, as if it was somebody completely 
different working on the design.



Absolutely.
  

:)
  

the above means that moving back to the original h1 example(s) I'd simply

h1whatever/h1



I'd probably do:

project:titleWhatever/project:title

Which would expand to:

h1 class=mainTitleWhateverjinn:accFlush
name=contentTitle/jinn:accFlush name=contentTitle
dyanmic=true//h1

Which would expand to a bunch of intermixed HTML/PHP code directly in
the requested document.

The reason for the accumulator flush is to add content to the title in
an unrelated area of the templates as is occasionally necessary. The
first inserts accumulated content during the build process, the second
allows insertion at run-time. Run-time is probably used more often since
it may be when editing a user profile or something and the name is
inserted into the title from the form controller. The compile time
version is used less often but has no run-time hit since it's pre-built.
  
I do like you're interjinn.. it's like a good coldfusion (no offense 
intented)
  

css:
h1 {
   color: rgb(255,0,0);
   font-size: 1.2em;
}

seeing as you can only have one h1 tag on a single document.



Says who?
  


well it's logical good practise I guess - not a hard and fast rule 
(although should probably be thought of as a rule..?)
H* tags are used to describe the semantic structure of a document, the 
H1 tag being used to describe what the entire document / page is about, 
then h2-h6 being used to split it into sub sections / sub headings. Thus 
two H1 tags indicates that the 

Re: [PHP] Couple of beginner questions

2009-01-11 Thread Robert Cummings
On Sun, 2009-01-11 at 18:14 +, Nathan Rixham wrote:
 Robert Cummings wrote:

  the above means that moving back to the original h1 example(s) I'd simply
 
  h1whatever/h1
  
 
  I'd probably do:
 
  project:titleWhatever/project:title
 
  Which would expand to:
 
  h1 class=mainTitleWhateverjinn:accFlush
  name=contentTitle/jinn:accFlush name=contentTitle
  dyanmic=true//h1
 
  Which would expand to a bunch of intermixed HTML/PHP code directly in
  the requested document.
 
  The reason for the accumulator flush is to add content to the title in
  an unrelated area of the templates as is occasionally necessary. The
  first inserts accumulated content during the build process, the second
  allows insertion at run-time. Run-time is probably used more often since
  it may be when editing a user profile or something and the name is
  inserted into the title from the form controller. The compile time
  version is used less often but has no run-time hit since it's pre-built.

 I do like you're interjinn.. it's like a good coldfusion (no offense 
 intented)

I've got to go do some crying... actually I've never used coldfusion, I
just wanted something that allowed embodying larger content
functionality in shorter syntax.


  css:
  h1 {
 color: rgb(255,0,0);
 font-size: 1.2em;
  }
 
  seeing as you can only have one h1 tag on a single document.
  
 
  Says who?

 
 well it's logical good practise I guess - not a hard and fast rule 
 (although should probably be thought of as a rule..?)
 H* tags are used to describe the semantic structure of a document, the 
 H1 tag being used to describe what the entire document / page is about, 
 then h2-h6 being used to split it into sub sections / sub headings. Thus 
 two H1 tags indicates that the document is two different documents. The 
 W3C site itself is normally a good indication for things like this, I'm 
 100% sure if you check the source for every page you'll not find a 
 single case where there are two H1 tags.
 
 example:
 http://www.w3.org/TR/xhtml1/
 
 from the source:
 
 h1a name=title id=title/a XHTML#8482; 1.0 The Extensible HyperText 
 Markup Language (Second Edition)/h1
 
 because the document is the XHTML™ 1.0 The Extensible HyperText Markup 
 Language (Second Edition) ; if there was a Third Edition it'd be in a 
 different document

That link you provided just above... open it up in the source viewer...
now do a search for h1 ... you'll be very surprised. H1 is merely a
level of heading... h1 being the most important on down to h6.

Cheers,
Rob.
-- 
http://www.interjinn.com
Application and Templating Framework for PHP


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



Re: [PHP] Couple of beginner questions

2009-01-11 Thread Nathan Rixham

Robert Cummings wrote:

On Sun, 2009-01-11 at 18:14 +, Nathan Rixham wrote:

Robert Cummings wrote:
  

the above means that moving back to the original h1 example(s) I'd simply

h1whatever/h1


I'd probably do:

project:titleWhatever/project:title

Which would expand to:

h1 class=mainTitleWhateverjinn:accFlush
name=contentTitle/jinn:accFlush name=contentTitle
dyanmic=true//h1

Which would expand to a bunch of intermixed HTML/PHP code directly in
the requested document.

The reason for the accumulator flush is to add content to the title in
an unrelated area of the templates as is occasionally necessary. The
first inserts accumulated content during the build process, the second
allows insertion at run-time. Run-time is probably used more often since
it may be when editing a user profile or something and the name is
inserted into the title from the form controller. The compile time
version is used less often but has no run-time hit since it's pre-built.
  
I do like you're interjinn.. it's like a good coldfusion (no offense 
intented)


I've got to go do some crying... actually I've never used coldfusion, I
just wanted something that allowed embodying larger content
functionality in shorter syntax.



like flex as well

  

css:
h1 {
   color: rgb(255,0,0);
   font-size: 1.2em;
}

seeing as you can only have one h1 tag on a single document.


Says who?
  
well it's logical good practise I guess - not a hard and fast rule 
(although should probably be thought of as a rule..?)
H* tags are used to describe the semantic structure of a document, the 
H1 tag being used to describe what the entire document / page is about, 
then h2-h6 being used to split it into sub sections / sub headings. Thus 
two H1 tags indicates that the document is two different documents. The 
W3C site itself is normally a good indication for things like this, I'm 
100% sure if you check the source for every page you'll not find a 
single case where there are two H1 tags.


example:
http://www.w3.org/TR/xhtml1/

from the source:

h1a name=title id=title/a XHTML#8482; 1.0 The Extensible HyperText Markup 
Language (Second Edition)/h1

because the document is the XHTML™ 1.0 The Extensible HyperText Markup 
Language (Second Edition) ; if there was a Third Edition it'd be in a 
different document


That link you provided just above... open it up in the source viewer...
now do a search for h1 ... you'll be very surprised. H1 is merely a
level of heading... h1 being the most important on down to h6.

Cheers,
Rob.


lmfao - cheers rob; completely and utterly take that one back - and 
actually after running that url through the semantic extractor 
(http://www.w3.org/2003/12/semantic-extractor.html) I can see how much 
sense it makes to have multiple h1's


I think my confusions came from too long working with internet marketers 
and thinking the web should be designed for googlebot.


cheers rob!

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



Re: [PHP] Couple of beginner questions

2009-01-11 Thread Robert Cummings
On Sun, 2009-01-11 at 21:01 +, Nathan Rixham wrote:
 Robert Cummings wrote:
 
  example:
  http://www.w3.org/TR/xhtml1/
 
  from the source:
 
  h1a name=title id=title/a XHTML#8482; 1.0 The Extensible
 HyperText Markup Language (Second Edition)/h1
 
  because the document is the XHTML™ 1.0 The Extensible HyperText
 Markup 
  Language (Second Edition) ; if there was a Third Edition it'd be
 in a 
  different document
  
  That link you provided just above... open it up in the source
 viewer...
  now do a search for h1 ... you'll be very surprised. H1 is merely
 a
  level of heading... h1 being the most important on down to h6.
  
  Cheers,
  Rob.
 
 lmfao - cheers rob; completely and utterly take that one back - and 
 actually after running that url through the semantic extractor 
 (http://www.w3.org/2003/12/semantic-extractor.html) I can see how much
 sense it makes to have multiple h1's
 
 I think my confusions came from too long working with internet
 marketers and thinking the web should be designed for googlebot.

I think with Googlebot the first h1 encountered in your document gets
the highest priority with respect to the page's content... expecially if
it matches with the page title and incoming link labels to the document.

Cheers,
Rob.
-- 
http://www.interjinn.com
Application and Templating Framework for PHP


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



Re: [PHP] Couple of beginner questions

2009-01-11 Thread Chris

tedd wrote:

At 11:35 AM -0800 1/9/09, VamVan wrote:
-- Remember as you re still a beginner try to avoid using ? at the 
end of

complete PHP code page. or else if you have empty lines at the end of the
file then you wont see blank page of death in PHP.


I'm not a beginner, but this is a practice that many other programmers 
advise, but I never follow. In my defense, I have never had the problem 
surface.


When you do, you'll know why we suggest it ;) It takes ages to find 
something like this - especially in a largish site or a large app with 
lots of php files.. any of the files included in a request can cause it.


--
Postgresql  php tutorials
http://www.designmagick.com/


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



Re: [PHP] Couple of beginner questions

2009-01-11 Thread John Corry
One of the best things that ever happened to me (with regards to
writing PHP) was deciding not to embed it in HTML anymore.

I either:
a) generate the HTML from classes I've built (HTML, Forms, Tables,
Images, etc) or use an equivalent PEAR class

- or -

b) Use Smarty templates...in which I still generate the HTML that will
go to the template (where required) with the HTML generation classes.

The advantages are abundant.

I can't imagine having to maintain some of the code I saw in the
examples above. My favorite WTF was with this snippet:

$imgHTML = 'img src=' . $url . ' alt=' . $alt . ' title=' . $alt
. ' class=' . $imgclass . ' /';

Holy crap...REALLY!?

All that string concatenation and there's not even width/height
attributes in there!

That would look like:

$i = new Image('path/to/image/file');
$i-__set(array('class'=$imgClass, 'alt' = $altText));
$i-toHtml();

Being able to change every image tag in a site by editing the
class/method that created is just too big an advantage not to use. Not
to mention the auto-generated width/height attributes, the ability to
auto-produce thumbnails and fullsize images from a single file...

After struggling through the beginnings, I wrote classes to generate
basic HTML elements, then tables, then forms, then images.

It saved me a bunch of time and taught me to see the website as an
application...not as a web-page with pieces of data in it.

Somehow, coming to that bit of knowledge was very helpful to my life
as a programmer.

Good luck,

John Corry

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



Re: [PHP] Couple of beginner questions

2009-01-11 Thread Paul M Foster
On Mon, Jan 12, 2009 at 12:04:15AM -0500, John Corry wrote:

 One of the best things that ever happened to me (with regards to
 writing PHP) was deciding not to embed it in HTML anymore.
 
 I either:
 a) generate the HTML from classes I've built (HTML, Forms, Tables,
 Images, etc) or use an equivalent PEAR class
 
 - or -
 
 b) Use Smarty templates...in which I still generate the HTML that will
 go to the template (where required) with the HTML generation classes.
 
 The advantages are abundant.
 
 I can't imagine having to maintain some of the code I saw in the
 examples above. My favorite WTF was with this snippet:
 
 $imgHTML = 'img src=' . $url . ' alt=' . $alt . ' title=' . $alt
 . ' class=' . $imgclass . ' /';
 
 Holy crap...REALLY!?
 
 All that string concatenation and there's not even width/height
 attributes in there!
 
 That would look like:
 
 $i = new Image('path/to/image/file');
 $i-__set(array('class'=$imgClass, 'alt' = $altText));
 $i-toHtml();
 
 Being able to change every image tag in a site by editing the
 class/method that created is just too big an advantage not to use. Not
 to mention the auto-generated width/height attributes, the ability to
 auto-produce thumbnails and fullsize images from a single file...
 
 After struggling through the beginnings, I wrote classes to generate
 basic HTML elements, then tables, then forms, then images.
 
 It saved me a bunch of time and taught me to see the website as an
 application...not as a web-page with pieces of data in it.
 
 Somehow, coming to that bit of knowledge was very helpful to my life
 as a programmer.

I've written a lot of code like the original example above, and still
do, but I see your point, since I've written code like yours too. I
write all my PHP code (and I write a *lot* of it) solo, with no help and
no collaborators. But as I understand it from a lot of framework types,
the ideal is to set up the HTML so that a HTML coder can understand
what's going on, without having a lot of PHP weirdness in it. Meaning,
if you're going to infuse your HTML with PHP, you should do it in a
minimalistic way. It'd be a helluva lot easier on me to do it all
through PHP classes, though.

I also come from a C background, and I recognize significant differences
between the paradigm for C programs and HTTP-based coding. Considering
that every PHP program paints generally a single page, I'm not a fan
of loading up 14 support files every time I load a page of HTML. That's
why I don't use one of the MVC frameworks available in the FOSS world.
CodeIgniter, which is one of the lightest weight frameworks, opens
something like 17 files before it paints a single byte in the browser.
The upshot is that I don't like to use a lot of libraries scattered in a
variety of files to render HTML/PHP pages.

But here's a question for those of you who work in a collaborative
environment-- are you really ever in a situation where some HTML weenie
is coding HTML pages and you're somewhere else doing the PHP work? Or is
that some academic's view of the way things *should* be done?

Paul
-- 
Paul M. Foster

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



Re: [PHP] Couple of beginner questions

2009-01-10 Thread tedd

At 12:18 PM -0500 1/9/09, Gary wrote:

I've done a number of sites in html and am now venturing into php.

Can I create a page in html and insert php code that will work? (for
example, take an existing page and insert a date command)

Can I create a page with the php extension that contains only contains html
and no php?  If so are there advantages/disadvantages?

Can I mix and match file formats (php/html) in a single site?

Thanks for any input.

Gary



Gary:

Welcome to the wonderful world of php.

As for your date question, try this:

http://sperling.com/examples/time/

As for mixing html and php, the following was the most important 
thing I learned about doing what you're trying to do:


http://sperling.com/examples/include-demo/

I think the demo is well worth your time to go through.

Hope this helps.

Cheers,

tedd

--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

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



Re: [PHP] Couple of beginner questions

2009-01-10 Thread Gary
Looks like a great link, thank you.

But am I to understand that all I need to do is change the extention on a 
file to php from html for all to be right with the world?

Gary
tedd tedd.sperl...@gmail.com wrote in message 
news:p06240803c58e55325...@[192.168.1.101]...
 At 12:18 PM -0500 1/9/09, Gary wrote:
I've done a number of sites in html and am now venturing into php.

Can I create a page in html and insert php code that will work? (for
example, take an existing page and insert a date command)

Can I create a page with the php extension that contains only contains 
html
and no php?  If so are there advantages/disadvantages?

Can I mix and match file formats (php/html) in a single site?

Thanks for any input.

Gary


 Gary:

 Welcome to the wonderful world of php.

 As for your date question, try this:

 http://sperling.com/examples/time/

 As for mixing html and php, the following was the most important thing I 
 learned about doing what you're trying to do:

 http://sperling.com/examples/include-demo/

 I think the demo is well worth your time to go through.

 Hope this helps.

 Cheers,

 tedd

 -- 
 ---
 http://sperling.com  http://ancientstones.com  http://earthstones.com 



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



Re: [PHP] Couple of beginner questions

2009-01-10 Thread tedd

At 11:35 AM -0800 1/9/09, VamVan wrote:

-- Remember as you re still a beginner try to avoid using ? at the end of
complete PHP code page. or else if you have empty lines at the end of the
file then you wont see blank page of death in PHP.


I'm not a beginner, but this is a practice that many other 
programmers advise, but I never follow. In my defense, I have never 
had the problem surface.


For me, I like closure and symmetry. If I *had* to not close a php 
segment, then I would find another way to do it so that I could.


But then again, I also never use else if statements either for the 
lack of symmetry they show to me (YMMV).


Cheers,

tedd

--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

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



Re: [PHP] Couple of beginner questions

2009-01-10 Thread tedd

At 8:48 AM -0500 1/10/09, Gary wrote:

Looks like a great link, thank you.

But am I to understand that all I need to do is change the extention on a
file to php from html for all to be right with the world?


Yup.

By changing the suffix (extension), you are telling the server that 
this file is to be treated differently than a html file. As such, the 
php interpreter will process the file before it is sent to the 
browser.


A statement like:

?php echo('Hello'); ?

Will print Hello to the browser. In fact, the browser will never 
see your php code unless you make a mistake. The file will be 
processed and delivered to the browser as html.


Please note that my use of echo above does not require the (), that's 
a habit I practice for no good reason whatsoever other than I like 
it. I think it's because I'm dyslectic and it makes sense to me.


In any event, I would consider the followingbad practice:

?php echo('h1Hello/h1'); ?

Whereas, the following I would consider good practice.

h1?php echo('Hello'); ?/h1

As best as you can, try to keep php and html separate.

I know that some have different ideas on good/bad practices, but 
you'll develop your own views/habits as you grow and learn.


Cheers,

tedd

--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

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



Re: [PHP] Couple of beginner questions

2009-01-10 Thread Paul M Foster
On Sat, Jan 10, 2009 at 09:46:14AM -0500, tedd wrote:

 At 8:48 AM -0500 1/10/09, Gary wrote:
 Looks like a great link, thank you.

 But am I to understand that all I need to do is change the extention on a
 file to php from html for all to be right with the world?

 Yup.

 By changing the suffix (extension), you are telling the server that
 this file is to be treated differently than a html file. As such, the
 php interpreter will process the file before it is sent to the
 browser.

 A statement like:

 ?php echo('Hello'); ?

 Will print Hello to the browser. In fact, the browser will never
 see your php code unless you make a mistake. The file will be
 processed and delivered to the browser as html.

 Please note that my use of echo above does not require the (), that's
 a habit I practice for no good reason whatsoever other than I like
 it. I think it's because I'm dyslectic and it makes sense to me.

 In any event, I would consider the followingbad practice:

 ?php echo('h1Hello/h1'); ?

 Whereas, the following I would consider good practice.

 h1?php echo('Hello'); ?/h1

 As best as you can, try to keep php and html separate.

 I know that some have different ideas on good/bad practices, but
 you'll develop your own views/habits as you grow and learn.

And let me present an alternative perspective. Never do something like:

?php echo 'Hellow world'; ?

Let Apache (or whatever) interpret HTML as HTML, and don't make it
interpret PHP code as HTML.

Instead, do:

h1Hello world/h1

If you're going to use PHP in the middle of a bunch of HTML, then only
use it where it's needed:

h1Hello ?php echo $name; ?/h1

The contents of the PHP $name variable can't be seen by the HTML, which
is why you need to enclose it in a little PHP island. Naturally, if
you're going to put PHP code in the middle of a HTML page, make the
extension PHP. Otherwise, Apache will not interpret the PHP code as PHP
(unless you do some messing with .htaccess or whatever). It's just
simplest to call a file something.php if it has PHP in it.

Paul
-- 
Paul M. Foster

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



Re: [PHP] Couple of beginner questions

2009-01-09 Thread Wolf

 Gary gwp...@ptd.net wrote: 
 I've done a number of sites in html and am now venturing into php.
 
 Can I create a page in html and insert php code that will work? (for 
 example, take an existing page and insert a date command)
Yup

 
 Can I create a page with the php extension that contains only contains html 
 and no php?  If so are there advantages/disadvantages?
Yujp
 
 Can I mix and match file formats (php/html) in a single site?
Yup

 Thanks for any input.
 
 Gary 
 
 
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 


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



Re: [PHP] Couple of beginner questions

2009-01-09 Thread Gary
Thanks for your input wolf, so would I be correct that the only advantage to 
having a page with a php extension is that you can use a testing server?

Thanks again.

gary
Wolf lonew...@nc.rr.com wrote in message 
news:20090109172254.7y5r1.75233.r...@cdptpa-web07-z01...

  Gary gwp...@ptd.net wrote:
 I've done a number of sites in html and am now venturing into php.

 Can I create a page in html and insert php code that will work? (for
 example, take an existing page and insert a date command)
 Yup


 Can I create a page with the php extension that contains only contains 
 html
 and no php?  If so are there advantages/disadvantages?
 Yujp

 Can I mix and match file formats (php/html) in a single site?
 Yup

 Thanks for any input.

 Gary



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

 



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



Re: [PHP] Couple of beginner questions

2009-01-09 Thread Eric Butera
On Fri, Jan 9, 2009 at 12:22 PM, Wolf lonew...@nc.rr.com wrote:

  Gary gwp...@ptd.net wrote:
 I've done a number of sites in html and am now venturing into php.

 Can I create a page in html and insert php code that will work? (for
 example, take an existing page and insert a date command)
 Yup

Um... if the file ext is .html and php isn't set to run that then nope.

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



Re: [PHP] Couple of beginner questions

2009-01-09 Thread Andrew Ballard
On Fri, Jan 9, 2009 at 12:18 PM, Gary gwp...@ptd.net wrote:
 I've done a number of sites in html and am now venturing into php.

 Can I create a page in html and insert php code that will work? (for
 example, take an existing page and insert a date command)

Not unless you configure your web server to parse all .html documents
with PHP first.

 Can I create a page with the php extension that contains only contains html
 and no php?  If so are there advantages/disadvantages?

Absolutely. The only real disadvantage I know of is the small overhead
from causing PHP to process a file that could otherwise be served
directly. That, and you'll possibly blow the use of client-side
caching of what is essentially static content.

 Can I mix and match file formats (php/html) in a single site?

Again, absolutely.

 Thanks for any input.

You're welcome.

 Gary

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



Re: [PHP] Couple of beginner questions

2009-01-09 Thread Wolf

 Eric Butera eric.but...@gmail.com wrote: 
 On Fri, Jan 9, 2009 at 12:22 PM, Wolf lonew...@nc.rr.com wrote:
 
   Gary gwp...@ptd.net wrote:
  I've done a number of sites in html and am now venturing into php.
 
  Can I create a page in html and insert php code that will work? (for
  example, take an existing page and insert a date command)
  Yup
 
 Um... if the file ext is .html and php isn't set to run that then nope.

That's a very good point  Getting PHP up and running will require the OP to 
read and follow the documentation.

But after that, you can mix and mingle at will, however good programming 
practices dictate that you become smart about your coding instead of dumping 
things in the original HTML and just playing.

Gotta be smart about things.

Wolf

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



Re: [PHP] Couple of beginner questions

2009-01-09 Thread Jason Pruim


On Jan 9, 2009, at 12:18 PM, Gary wrote:


I've done a number of sites in html and am now venturing into php.

Can I create a page in html and insert php code that will work? (for
example, take an existing page and insert a date command)


Yes you can ?PHP echo date(m/d/y h:i:s, time()); ?



Can I create a page with the php extension that contains only  
contains html

and no php?  If so are there advantages/disadvantages?
Yes, Look at heredoc syntax on the php.net site. Works really well  
for a few pages that I use.




Can I mix and match file formats (php/html) in a single site?


Yes. You can easily mix and match, in fact... if you go one step  
further... You can remove the extension's all together from the files  
so that you can change it as needed and not screw up any links that  
you have already created.



--
Jason Pruim
japr...@raoset.com
616.399.2355





Re: [PHP] Couple of beginner questions

2009-01-09 Thread Eric Butera
On Fri, Jan 9, 2009 at 12:18 PM, Gary gwp...@ptd.net wrote:
 Can I create a page with the php extension that contains only contains html
 and no php?  If so are there advantages/disadvantages?

 Can I mix and match file formats (php/html) in a single site?

If it were me, I'd make sure all the files were .php.  If you have a
page right now that is static, but needs to become dynamic, then
you're in for some hurt.  Never create 404's.  You can of course do a
301 redirect to indicate the html has moved to php, but that is really
annoying.  The best solution though is to not have any file extensions
on your urls to begin with.  That is out of the scope of this email
though.

You can force php to run .html files, but then you've just really
killed the performance of your web host.  Servers are really fast at
serving static files, but the second you load php, even to just do a
?php echo 'hello world' ? you've slashed your maximum requests per
second significantly.

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



Re: [PHP] Couple of beginner questions

2009-01-09 Thread Dan Shirah
 so would I be correct that the only advantage to
 having a page with a php extension is that you can use a testing server?


There are FAR more benefits!

1) PHP is FREE!  So you save money from the get go
2) PHP is open source!  So it is constantly being updated and improved by
users/devs.
3) PHP is processed on the SERVER.  This frees up CPU usage on the user's
workstation.
4)PHP can retieve data from a centralized database which makes dynamic
content easier to use.
5) Since PHP is server side, you are not reliant on the end users to have
specialized plugins/software to view your pages.
6) PHP is easy. IMO one of the easier languages ot learn.
7) PHP has a great community. (See peopel on this list)

And many many more reasons you will learn as you go! :)


Re: [PHP] Couple of beginner questions

2009-01-09 Thread Gary
Dan

I think you misunderstood the question. The question was not is there an 
advantage of php over html, but the advantage of having a file with the 
extension of php over an extension of html.


Dan Shirah mrsqua...@gmail.com wrote in message 
news:a16da1ff0901091019m3d513ebeyf341b2d39c669...@mail.gmail.com...
 so would I be correct that the only advantage to
 having a page with a php extension is that you can use a testing server?


 There are FAR more benefits!

 1) PHP is FREE!  So you save money from the get go
 2) PHP is open source!  So it is constantly being updated and improved by
 users/devs.
 3) PHP is processed on the SERVER.  This frees up CPU usage on the user's
 workstation.
 4)PHP can retieve data from a centralized database which makes dynamic
 content easier to use.
 5) Since PHP is server side, you are not reliant on the end users to have
 specialized plugins/software to view your pages.
 6) PHP is easy. IMO one of the easier languages ot learn.
 7) PHP has a great community. (See peopel on this list)

 And many many more reasons you will learn as you go! :)
 



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



Re: [PHP] Couple of beginner questions

2009-01-09 Thread Andrew Ballard
On Fri, Jan 9, 2009 at 12:47 PM, Jason Pruim japr...@raoset.com wrote:

 On Jan 9, 2009, at 12:18 PM, Gary wrote:

 Can I create a page with the php extension that contains only contains
 html
 and no php?  If so are there advantages/disadvantages?

 Yes, Look at heredoc syntax on the php.net site. Works really well for a few
 pages that I use.

You don't need heredoc for a page that doesn't have any PHP code in it.

file: HelloWorld.php

html
body
pHello World/p
/body
/html


This is a prefectly valid PHP page.


 Can I mix and match file formats (php/html) in a single site?

 Yes. You can easily mix and match, in fact... if you go one step further...
 You can remove the extension's all together from the files so that you can
 change it as needed and not screw up any links that you have already
 created.

How would you do that? The options I can think of involve:

1) You have to either configure the web server to serve everything
(including images, flash content, javascript, CSS, etc.) through PHP
-- or at least anything without a handled mime-type.

2) You have to configure the web server to use something like
mod_rewrite to point URLs to the correct script.

3) You create a folder for every unique page in the entire site and
each folder contains exactly one file named either index.php or
index.html (or whatever the default document name is for your web
server).

Andrew

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



Re: [PHP] Couple of beginner questions

2009-01-09 Thread VamVan
Hey Gary,

I've done a number of sites in html and am now venturing into php.

Can I create a page in html and insert php code that will work? (for
example, take an existing page and insert a date command)

--- Of course you can do that. But it is not advised. Becoming better in PHP
in few months you will understand that its almost necessary to separate
business logic from presentation logic. But as a beginner you can do that.
So basically have ?php ? tags around the php code that you write. better
to rename your files to .php extension.

Can I create a page with the php extension that contains only contains html
and no php?  If so are there advantages/disadvantages?

-- Yes you can do that but if you have ?php  ? it better to wrap your html
in quotes and also escape them and print it on the screen using echo command
or print command. echo is better though. or else if you dont want to open
?php ? tags then you can have plain html without any hassle.

-- Remember as you re still a beginner try to avoid using ? at the end of
complete PHP code page. or else if you have empty lines at the end of the
file then you wont see blank page of death in PHP.

Can I mix and match file formats (php/html) in a single site?

-- Every wesbite in this world not only in PHP or anywhere is a combination
of html (presenation layer) and PHP (Logic). So the asnwer is yes.

Thanks,
V


Re: [PHP] Couple of beginner questions

2009-01-09 Thread ceo

The slowdown of just running raw HTML through PHP was once benchmarked as about 
5 to 10 %.



You could, in theory, use .htaccess and Files to ForceType specific .html 
files as PHP, while leaving the rest of your .html files as static.



I am not recommending this, just being pedantic. :-)



Definitely better to either do them all and take performance hit, which is 
probably irrelevant to a beginner, or plan better now and strip .xyz from the 
URLs.



ymmv.



Personally, I've been quite happy for over a decade running all .html through 
PHP, on 99% of the sites I work on.



If it's big enough to *need* static content, they usually have already gone the 
route of CDN and have static HTML off on those nodes anyway, in my limited 
experience.



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



Re: [PHP] Couple of beginner questions

2009-01-09 Thread Eric Butera
On Fri, Jan 9, 2009 at 3:22 PM,  c...@l-i-e.com wrote:

 The slowdown of just running raw HTML through PHP was once benchmarked as 
 about 5 to 10 %.

 You could, in theory, use .htaccess and Files to ForceType specific .html 
 files as PHP, while leaving the rest of your .html files as static.

 I am not recommending this, just being pedantic. :-)

 Definitely better to either do them all and take performance hit, which is 
 probably irrelevant to a beginner, or plan better now and strip .xyz from the 
 URLs.

 ymmv.

 Personally, I've been quite happy for over a decade running all .html through 
 PHP, on 99% of the sites I work on.

 If it's big enough to *need* static content, they usually have already gone 
 the route of CDN and have static HTML off on those nodes anyway, in my 
 limited experience.

I was just talking myself.  I use objects and such so I'm really not
as worried about performance either.  But it was a downside that I
knew about from some css/js stuff I'd done a while ago.  I still had 2
files on my box from some framework stuff I'd been messing with.  Here
were some results from my local testing (from the Yii framework).


-- index.html --
$ cat index.html
hello world

$ ab -t 30 -c 50 http://localhost/benchmarks/baseline/index.html
Requests per second:631.07 [#/sec] (mean)
Time per request:   79.23 [ms] (mean)
Time per request:   1.58 [ms] (mean, across all concurrent requests)


-- index.php --
$ cat index.php
?php echo hello world ?

$ ab -t 30 -c 50 http://localhost/benchmarks/baseline/index.php
Requests per second:358.21 [#/sec] (mean)
Time per request:   139.58 [ms] (mean)
Time per request:   2.79 [ms] (mean, across all concurrent requests)

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



Re: [PHP] Couple of beginner questions

2009-01-09 Thread Daniel Brown
On Fri, Jan 9, 2009 at 15:36, Eric Butera eric.but...@gmail.com wrote:

 I was just talking myself.  I use objects and such so I'm really not
 as worried about performance either.  But it was a downside that I
 knew about from some css/js stuff I'd done a while ago.  I still had 2
 files on my box from some framework stuff I'd been messing with.  Here
 were some results from my local testing (from the Yii framework).

Great benchmarks, Eric.

Another very, very important point is to consider the number of
extensions and core build of your local PHP engine.  The more options
that are compiled in, the larger the memory footprint, and the greater
amount of time it will take to load, parse, process, and return to the
HTTP server.  It may be negligible to the end-user for a single
request, but high-traffic sites could create a noticeable slowdown on
some servers.

-- 
/Daniel P. Brown
daniel.br...@parasane.net || danbr...@php.net
http://www.parasane.net/ || http://www.pilotpig.net/
Unadvertised dedicated server deals, too low to print - email me to find out!

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



Re: [PHP] Couple of beginner questions

2009-01-09 Thread Frank Stanovcak

VamVan vamsee...@gmail.com wrote in message 
news:12eb8b030901091135u4e17f1f3p24698dbc8f5a2...@mail.gmail.com...

 -- Remember as you re still a beginner try to avoid using ? at the end of
 complete PHP code page. or else if you have empty lines at the end of the
 file then you wont see blank page of death in PHP.


I never knew this.  Could this be why I get 401 errors if a page throws an 
error with out a successful run first?

as in if I load up the page and there is an error I get 401, but if I upload 
a blank file with the same name, load that, then upload the errant code and 
refresh I can suddenly see an error?

Frank 



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



Re: [PHP] Couple of beginner questions

2009-01-09 Thread ceo

With all due respect, Eric, you're not testing what we're discussing.



A real CLI test would be more like:



time cat foo.html

time php -q foo.html



I.E., how long does PHP take to read/write foo.html without breaking into PHP 
mode for static HTML.



Of course, it's still a lousy benchmark with CLI instead of Apache wrapper, but 
you get my point, I trust.



Q: How much slower is it to force all static .html files through PHP wrapper of 
Apache?

A: About 5 to 10 % (as of a couple years ago...)



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



Re: [PHP] Couple of beginner questions

2009-01-09 Thread Eric Butera
On Fri, Jan 9, 2009 at 4:45 PM,  c...@l-i-e.com wrote:

 With all due respect, Eric, you're not testing what we're discussing.

 A real CLI test would be more like:

 time cat foo.html
 time php -q foo.html

 I.E., how long does PHP take to read/write foo.html without breaking into PHP 
 mode for static HTML.

 Of course, it's still a lousy benchmark with CLI instead of Apache wrapper, 
 but you get my point, I trust.

 Q: How much slower is it to force all static .html files through PHP wrapper 
 of Apache?
 A: About 5 to 10 % (as of a couple years ago...)


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



In my original post I was talking about the time it takes to run the
full apache-php whatever cycle vs just apache.  I wasn't trying to do
a cli test.  I use mod php which runs them based on file extension, so
I used ab w/ 2 different files.  I'm not trying to be difficult (for
once ;), I just don't follow what you're talking about?

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



Re: [PHP] Couple of beginner questions

2009-01-09 Thread ceo

I'm talking about having PHP rip through .html files without any

?php echo *;?

inside of them.



You added ?php echo *; ?



Don't do that. :-)



ln -s foo.html foo.php



Surf to both and time it.



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



Re: [PHP] Couple of beginner questions

2009-01-09 Thread Eric Butera
On Fri, Jan 9, 2009 at 5:53 PM,  c...@l-i-e.com wrote:

 I'm talking about having PHP rip through .html files without any
 ?php echo *;?
 inside of them.

 You added ?php echo *; ?

 Don't do that. :-)

 ln -s foo.html foo.php

 Surf to both and time it.


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



Is this better?

$ cat hello-world.html
Hello World

$ ab -c 50 -t 30 http://localhost/benchmarks/hello-world.html
Requests per second:4030.52 [#/sec] (mean)
Time per request:   12.405 [ms] (mean)
Time per request:   0.248 [ms] (mean, across all concurrent requests)

Requests per second:4730.00 [#/sec] (mean)
Time per request:   10.571 [ms] (mean)
Time per request:   0.211 [ms] (mean, across all concurrent requests)
Transfer rate:  1529.37 [Kbytes/sec] received

Requests per second:4866.09 [#/sec] (mean)
Time per request:   10.275 [ms] (mean)
Time per request:   0.206 [ms] (mean, across all concurrent requests)
Transfer rate:  1573.24 [Kbytes/sec] received

Requests per second:4313.09 [#/sec] (mean)
Time per request:   11.593 [ms] (mean)
Time per request:   0.232 [ms] (mean, across all concurrent requests)
Transfer rate:  1394.62 [Kbytes/sec] received

$ mv hello-world.php hello-world.html

$ ab -c 50 -t 30 http://localhost/benchmarks/hello-world.php
Requests per second:2649.66 [#/sec] (mean)
Time per request:   18.870 [ms] (mean)
Time per request:   0.377 [ms] (mean, across all concurrent requests)
Transfer rate:  685.87 [Kbytes/sec] received

Requests per second:2774.03 [#/sec] (mean)
Time per request:   18.024 [ms] (mean)
Time per request:   0.360 [ms] (mean, across all concurrent requests)
Transfer rate:  718.05 [Kbytes/sec] received

Requests per second:2722.94 [#/sec] (mean)
Time per request:   18.363 [ms] (mean)
Time per request:   0.367 [ms] (mean, across all concurrent requests)
Transfer rate:  704.79 [Kbytes/sec] received

Requests per second:2769.77 [#/sec] (mean)
Time per request:   18.052 [ms] (mean)
Time per request:   0.361 [ms] (mean, across all concurrent requests)
Transfer rate:  717.00 [Kbytes/sec] received

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