php-general Digest 11 Apr 2009 23:25:13 -0000 Issue 6062

2009-04-11 Thread php-general-digest-help

php-general Digest 11 Apr 2009 23:25:13 - Issue 6062

Topics (messages 291361 through 291371):

Re: Caching
291361 by: Richard Heyes

Random php
291362 by: Gary
291363 by: Phpster
291364 by: Gary
291368 by: Gary
291369 by: 9el

Re: Escape Data In/Out of db [solved]
291365 by: Shawn McKenzie

Sobre Login PHP
291366 by: Alejandro Esteban Galvez
291367 by: Daniel Brown

extract varying data from array with different formatting
291370 by: PJ

Additional support for your family!
291371 by: Forest Bennett

Administrivia:

To subscribe to the digest, e-mail:
php-general-digest-subscr...@lists.php.net

To unsubscribe from the digest, e-mail:
php-general-digest-unsubscr...@lists.php.net

To post to the list, e-mail:
php-gene...@lists.php.net


--
---BeginMessage---
 Hey! About   Header set Expires Thu, 15 Apr 2010 20:00:00 GMT 
 The problem is the files might change, lets say - every week. How can I use
  Header set Expires Thu, 15 Apr 2010 20:00:00 GMT to something like

 Header set Expires today plus week

 (or X seconds / y minutes / etc...)

In that case you will want to use Cache-Control instead:

Header set Cache-Control private,public,max-age=604800

The max-age is the number of seconds (1 week in this case) that the
page is cached for. The private and public determine which kinds of
cache should cache it. IIRC (which isn't likely).

-- 
Richard Heyes

HTML5 Canvas graphing for Firefox, Chrome, Opera and Safari:
http://www.rgraph.net (Updated April 11th)
---End Message---
---BeginMessage---
Is there a way to have a php include called ramdomly?  For example, I have 
an area that I am using to show various quotes and I would like the quotes 
to be ramdom.

Thanks for your help

Gary 


---End Message---
---BeginMessage---



On Apr 11, 2009, at 10:12, Gary gwp...@ptd.net wrote:

Is there a way to have a php include called ramdomly?  For example,  
I have
an area that I am using to show various quotes and I would like the  
quotes

to be ramdom.

Thanks for your help

Gary



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



Best is to use a storage system ( either file with a quote in each  
line or a database ) and then randomly select  a record from the  
database or an item from the file. If you do a quick search on www.hotscripts.com 
 or just goodle 'php random quote' you'll see lots of samples or  
complete code.


Bastien
---End Message---
---BeginMessage---
Thanks much for your quick reply, I'll take a look (and maybe even find one 
that spell checks my posts first!).

Gary


Phpster phps...@gmail.com wrote in message 
news:146a4da4-0114-474c-92f8-b8d3a5ecc...@gmail.com...


 On Apr 11, 2009, at 10:12, Gary gwp...@ptd.net wrote:

 Is there a way to have a php include called ramdomly?  For example,  I 
 have
 an area that I am using to show various quotes and I would like the 
 quotes
 to be ramdom.

 Thanks for your help

 Gary



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


 Best is to use a storage system ( either file with a quote in each  line 
 or a database ) and then randomly select  a record from the  database or 
 an item from the file. If you do a quick search on www.hotscripts.com or 
 just goodle 'php random quote' you'll see lots of samples or  complete 
 code.

 Bastien 


---End Message---
---BeginMessage---
I had been on that site before, but seems like it is a breeding ground for 
spam and links to free commercial sites.  Ran into a few bad or broken 
links, several listings as different scripts only to take you to the same 
best price hosting company with no scripts at all.  Is this common, is 
that site on its way out?

Would you have another suggestion?

Thanks for your help.

Gary


Phpster phps...@gmail.com wrote in message 
news:146a4da4-0114-474c-92f8-b8d3a5ecc...@gmail.com...


 On Apr 11, 2009, at 10:12, Gary gwp...@ptd.net wrote:

 Is there a way to have a php include called ramdomly?  For example,  I 
 have
 an area that I am using to show various quotes and I would like the 
 quotes
 to be ramdom.

 Thanks for your help

 Gary



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


 Best is to use a storage system ( either file with a quote in each  line 
 or a database ) and then randomly select  a record from the  database or 
 an item from the file. If you do a quick search on www.hotscripts.com or 
 just goodle 'php random quote' you'll see lots of samples or  complete 
 code.

 Bastien 


---End Message---
---BeginMessage---
On Sun, Apr 12, 2009 at 1:32 AM, Gary gwp...@ptd.net wrote:

 I had been on that site before, but seems like it is a breeding ground for
 spam and links to free commercial sites.  Ran into a few 

Re: [PHP] concat and join stuff

2009-04-11 Thread Martijn Korse

This is not really a PHP question, but a mysql question.

Anyways, your query should work, as far as i can see.

If you give the structure dumps and some relevant data dumps i don't mind to
give it a try here.

-
http://devshed.excudo.net http://devshed.excudo.net 
-- 
View this message in context: 
http://www.nabble.com/concat-and-join-stuff-tp22874340p22999438.html
Sent from the PHP - General mailing list archive at Nabble.com.


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



Re: [PHP] Caching

2009-04-11 Thread Richard Heyes
 Hey! About   Header set Expires Thu, 15 Apr 2010 20:00:00 GMT 
 The problem is the files might change, lets say - every week. How can I use
  Header set Expires Thu, 15 Apr 2010 20:00:00 GMT to something like

 Header set Expires today plus week

 (or X seconds / y minutes / etc...)

In that case you will want to use Cache-Control instead:

Header set Cache-Control private,public,max-age=604800

The max-age is the number of seconds (1 week in this case) that the
page is cached for. The private and public determine which kinds of
cache should cache it. IIRC (which isn't likely).

-- 
Richard Heyes

HTML5 Canvas graphing for Firefox, Chrome, Opera and Safari:
http://www.rgraph.net (Updated April 11th)

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



[PHP] Random php

2009-04-11 Thread Gary
Is there a way to have a php include called ramdomly?  For example, I have 
an area that I am using to show various quotes and I would like the quotes 
to be ramdom.

Thanks for your help

Gary 



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



Re: [PHP] Random php

2009-04-11 Thread Phpster



On Apr 11, 2009, at 10:12, Gary gwp...@ptd.net wrote:

Is there a way to have a php include called ramdomly?  For example,  
I have
an area that I am using to show various quotes and I would like the  
quotes

to be ramdom.

Thanks for your help

Gary



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



Best is to use a storage system ( either file with a quote in each  
line or a database ) and then randomly select  a record from the  
database or an item from the file. If you do a quick search on www.hotscripts.com 
 or just goodle 'php random quote' you'll see lots of samples or  
complete code.


Bastien

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



Re: [PHP] Random php

2009-04-11 Thread Gary
Thanks much for your quick reply, I'll take a look (and maybe even find one 
that spell checks my posts first!).

Gary


Phpster phps...@gmail.com wrote in message 
news:146a4da4-0114-474c-92f8-b8d3a5ecc...@gmail.com...


 On Apr 11, 2009, at 10:12, Gary gwp...@ptd.net wrote:

 Is there a way to have a php include called ramdomly?  For example,  I 
 have
 an area that I am using to show various quotes and I would like the 
 quotes
 to be ramdom.

 Thanks for your help

 Gary



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


 Best is to use a storage system ( either file with a quote in each  line 
 or a database ) and then randomly select  a record from the  database or 
 an item from the file. If you do a quick search on www.hotscripts.com or 
 just goodle 'php random quote' you'll see lots of samples or  complete 
 code.

 Bastien 



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



Re: [PHP] Escape Data In/Out of db [solved]

2009-04-11 Thread Shawn McKenzie
tedd wrote:
 At 9:12 PM -0700 4/9/09, Jim Lucas wrote:
 tedd wrote:
 At 5:03 PM +0200 4/9/09, Jan G.B. wrote:

 You might want to use htmlspecialchars($str, ENT_QUOTES)

 OUT from db to html

 and

 mysql_real_escape_string(stripslashes($_POST['yourself']));


 The above tells me that you probably need to look at your magic quotes
 setting.
 
 The php info says:
 
 magic_quotes_runtimeOffOff
 magic_quotes_sybaseOffOff
 
 I'm assuming that means OFF, right?
 
 Cheers,
 
 tedd

I think you want to look for magic_quotes_gpc


-- 
Thanks!
-Shawn
http://www.spidean.com

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



[PHP] Sobre Login PHP

2009-04-11 Thread Alejandro Esteban Galvez

Saludos colegas, los otros dias, estuve escribiendo acerca de esto, y bueno ya 
tengo una parte ahora necesito que cuando se cierre el navegador, se cierre la 
sesion de login tambien.  Saludos


---
Alejandro Esteban Galvez
Administrador de Red IPICHMC Rimed,
Radio-Aficionado CL2AEG
Linux User #472120 - http://i18n.counter.li.org/
Correo: alejan...@infomed.sld.cu
Correo y Jabber: alejan...@ipichmc.rimed.cu
www.ipichmc.rimed.cu
---





---
Red Telematica de Salud - Cuba

  CNICM - Infomed




Re: [PHP] Sobre Login PHP

2009-04-11 Thread Daniel Brown
2009/4/11 Alejandro Esteban Galvez alejan...@infomed.sld.cu:

 Saludos colegas, los otros dias, estuve escribiendo acerca de esto, y bueno 
 ya tengo una parte ahora necesito que cuando se cierre el navegador, se 
 cierre la sesion de login tambien.  Saludos

Saludos, Alejandro;

Envíe por favor este mensaje a la lista española del PHP en
php-general...@lists.php.net. Usted puede suscribir a la lista en
http://php.net/mailinglists.  Solo inglés a este lista.

¡Gracias, y Pascua feliz!

-- 
/Daniel P. Brown
daniel.br...@parasane.net || danbr...@php.net
http://www.parasane.net/ || http://www.pilotpig.net/
50% Off All Shared Hosting Plans at PilotPig: Use Coupon DOW1

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



Re: [PHP] Random php

2009-04-11 Thread Gary
I had been on that site before, but seems like it is a breeding ground for 
spam and links to free commercial sites.  Ran into a few bad or broken 
links, several listings as different scripts only to take you to the same 
best price hosting company with no scripts at all.  Is this common, is 
that site on its way out?

Would you have another suggestion?

Thanks for your help.

Gary


Phpster phps...@gmail.com wrote in message 
news:146a4da4-0114-474c-92f8-b8d3a5ecc...@gmail.com...


 On Apr 11, 2009, at 10:12, Gary gwp...@ptd.net wrote:

 Is there a way to have a php include called ramdomly?  For example,  I 
 have
 an area that I am using to show various quotes and I would like the 
 quotes
 to be ramdom.

 Thanks for your help

 Gary



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


 Best is to use a storage system ( either file with a quote in each  line 
 or a database ) and then randomly select  a record from the  database or 
 an item from the file. If you do a quick search on www.hotscripts.com or 
 just goodle 'php random quote' you'll see lots of samples or  complete 
 code.

 Bastien 



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



Re: [PHP] Random php

2009-04-11 Thread 9el
On Sun, Apr 12, 2009 at 1:32 AM, Gary gwp...@ptd.net wrote:

 I had been on that site before, but seems like it is a breeding ground for
 spam and links to free commercial sites.  Ran into a few bad or broken
 links, several listings as different scripts only to take you to the same
 best price hosting company with no scripts at all.  Is this common, is
 that site on its way out?

 Would you have another suggestion?


Well, I also browsed through that site.. yes what you claimed is true.
Facility/Opportunity comes with a price. So, you can go through the
ads/sponsors but there are working examples/free code snippets as well.

Just googling with that  random quote php could yield you a lots of
practical results.

Regards

Lenin

www.twitter.com/nine_L


[PHP] extract varying data from array with different formatting

2009-04-11 Thread PJ
foreach does a nice job if you want the results identical each time.
What can you use to change the formatting of the results dependent on
the number of results.
Here's an example:
foreach ( $authors[$bookID] AS $authorID = $authorData ) {
# Display the
echo {$authorData['first_name']} 
{$authorData['last_name']}\n;
}

will echo - Joe Boe John Blue Andy Candy etc depending on how many rows
we have.
What I want is: Joe Boe, John Blue, Andy Candy  Hans Stick ( separated
by commas, except for the last one which is separated with  .
I thought of passing a variable to the foreach and then using if
elseif... but that can't work because the variable is reset to 0 after
each pass.
Can't get switch to do it (maybe I don't understand it right.
Help ?

-- 
unheralded genius: A clean desk is the sign of a dull mind. 
-
Phil Jourdan --- p...@ptahhotep.com
   http://www.ptahhotep.com
   http://www.chiccantine.com/andypantry.php


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



[PHP] $_GET

2009-04-11 Thread Ron Piggott
I am moving my web site to a new host this weekend.  I am working
towards making the code compatible to the structure of the new server.

I am getting a weird response which I don't understand

At the very start of my index.php I have the following lines of code:

foreach($_GET as $key = $val) {
$$key = $_GET[$val];
echo $_GET[$val] . br /;
}

What I don't understand is why the output is

br /br /

I am not understanding how two empty variables are being passed.

index.php is driven off of various mod re-writes contained
within .htaccess .  This is why I am doing the loop above.

RewriteRule ^page/([^/\.]+)/?$ index.php?page=$1 [L]
RewriteRule ^page/([^/\.]+)/([^/\.]+)/?$ index.php?page=$1field1=$2 [L]
RewriteRule ^page/([^/\.]+)/([^/\.]+)/([^/\.]+)/?$ index.php?page=
$1field1=$2field2=$3 [L]

What should I be trying?  What will allow the value of page to be passed
onto $page with the following URL:

http://www.actsministrieschristianevangelism.org/page/home_page/ 


Re: [PHP] Additional support for your family!

2009-04-11 Thread 9el
2009/4/12 Forest Bennett tha...@psv.com.vn

 Good day, Dear Mr. or Ms!

 Are you in need for money but you don't have the time and nerve for a
 secondary job? Here is your chance to be part of a program that is taking
 traditional marketing research in a brand new direction, with the ease of
 the Internet technologies!

 Our participants are always rewarded for their precious opinion.

 Here is what amounts you can earn:

 - From $5 to $100 per online survey
 - From $50 to $200 for an online focus group discussion
 - From $30 to $120 per product and service evaluation

 Please excuse us if this letter is unwanted for you or we have disturbed
 you in some way, but this inquiry is serious and sincere!

 Please reply to 1485keenan.sm...@gmail.com for further information. Join
 us now because the places are limited!

 Best regards,
 Consumer Opinion Administration











 --
 This email has been written and proved to be in compliance with the
 recently established can-spam act law in US. We are not provoking or forcing
 any person in any way to participate in our programs. To participate is your
 own decision and you carry the responsibility of taking further part in this
 promotion. Anyway, if you don't want to receive more good offers from us,
 you can simply Unsubscribe by sending us a notification email to
 out_of_the_l...@yahoo.com with a mail-subject and text Unsubscribe me,
 and we will get your email out of our list within 10 days.

 This message is STRICTLY CONFIDENTIAL and is solely for the individual or
 organisation to whom it is addressed. It may contain PRIVILEGED and
 CONFIDENTIAL information. If you are not the intended recipient, you are
 hereby notified that any dissemination, distribution or copying of this
 communication and its contents is strictly prohibited. If you are not the
 intended recipient you should not read, copy, distribute, disclose or
 otherwise use the information in this email. Email may be susceptible to
 data corruption, interception and unauthorised amendment, and we do not
 accept liability for any such corruption, interception or amendment or the
 consequences thereof or your reliance on any information contained therein
 if you are not the intended recipient. If you are not interested in the
 offered promotions, please just don't answer. If you think you have received
 this message and its contents in error, please delete it from your computer,
 or follow the unsubscribing procedure shown above.
 --


Ah! could you just pay in my paypal? bluh!


Re: [PHP] Additional support for your family!

2009-04-11 Thread Daniel Brown
On Sat, Apr 11, 2009 at 19:29, 9el le...@phpxperts.net wrote:

 Ah! could you just pay in my paypal? bluh!

For future reference, the general practice on the list is not even
to acknowledge the email.

-- 
/Daniel P. Brown
daniel.br...@parasane.net || danbr...@php.net
http://www.parasane.net/ || http://www.pilotpig.net/
50% Off All Shared Hosting Plans at PilotPig: Use Coupon DOW1

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



Re: [PHP] Escape Data In/Out of db [solved]

2009-04-11 Thread Shawn McKenzie
tedd wrote:
 I think you want to look for magic_quotes_gpc


 -- 
 Thanks!
 -Shawn


 -Shawn:

 You were right.

 I'll fix it.

 Thanks,

 tedd

I normally have a prep4display() and prep4store() type function that do
all of the sensitization/prep for either storing or displaying.  So
prep4display() has a check for magic_quotes_gpc for which it does
stripslashes() if they are on and then htmlentities() etc.. and the
prep4store() can do mysql_real_escape_string() and whatever else.

-Shawn

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



Re: [PHP] $_GET

2009-04-11 Thread Mark Kelly
Hi.

On Sunday 12 April 2009, Ron Piggott wrote:
 At the very start of my index.php I have the following lines of code:

 foreach($_GET as $key = $val) {
 $$key = $_GET[$val];
 echo $_GET[$val] . br /;
 }

Try:

echo $_GET[$key] . br /;

HTH

Mark

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



Re: [PHP] How about a saveXHTML for the DOM?

2009-04-11 Thread Raymond Irving


If I remove the \r from the file using preg_replace() then it shows up just 
fine. I was just wondering if there was a way to suppress the \r in the xml 
output.

Another thing that I've observed while looking at your code is that it only 
works best for dynamic web pages. It appears that it would not work well when 
using page caching or page templates.

I really think having a function that generates xhtml (html compatible) output, 
would really eliminate all these workarounds that we will have to do in order 
to get the page to render inside popular web browsers.

A lot of developers produce xhtml web pages that are html 4 compatible, so that 
they can be rendered in browsers that only supports html rendering. This is 
something that I think the PHP DOM should be able to support with ease.



Best regards,
__
Raymond Irving



--- On Fri, 4/10/09, Michael A. Peters mpet...@mac.com wrote:

 From: Michael A. Peters mpet...@mac.com
 Subject: Re: [PHP] How about a saveXHTML for the DOM?
 To: Raymond Irving xwis...@yahoo.com
 Cc: php-general@lists.php.net php-general@lists.php.net
 Date: Friday, April 10, 2009, 6:35 PM
 Raymond Irving wrote:
  
  Thanks for the feedback Michael. I will look into your
 suggesstions.
  
  Is there an option on the DOMDocument that we can set
 to not have saveXML() append 
 to the end of the tags?
  
  This is normally the case if the html content was
 loaded using loadHTMLFile()
 
 I think I've seen that appear in textarea as well - I
 believe it has to do with the libebreaks of the application
 that created the file (or in case of textarea from a form,
 the line break convention of the browser).
 
 Does it happen when you run
 
 sed -i 's/\r//g' file.html
 
 to remove the DOS carriage return from the line breaks?
 
 That would be my guess.
 
 -- 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] Escape Data In/Out of db [solved]

2009-04-11 Thread Shawn McKenzie
Shawn McKenzie wrote:
 tedd wrote:
 I think you want to look for magic_quotes_gpc


 -- 
 Thanks!
 -Shawn

 -Shawn:

 You were right.

 I'll fix it.

 Thanks,

 tedd
 
 I normally have a prep4display() and prep4store() type function that do
 all of the sensitization/prep for either storing or displaying.  So
 prep4display() has a check for magic_quotes_gpc for which it does
 stripslashes() if they are on and then htmlentities() etc.. and the
 prep4store() can do mysql_real_escape_string() and whatever else.
 
 -Shawn

Well, since this last post didn't make a whole lot of sense I thought
I'd clarify and add a little.  So I use the prep4display() in an echo or
when building display output and prep4store() in a query etc.

The addition that I find useful sometimes are clean_from_input() and
clean_for_output() type functions which may use the aforementioned ones.
clean_from_input() you can call like  clean_from_input('some_getvar')
and it will check to see if the $_GET var (or more generally $_REQUEST
or $_GET || $_POST) is set and return after stripping slashes if
magic_quotes_gpc is set and whatever else.  Then the clean_for_output()
does some stuff for output when you need it.  My point is that if you
build a function to retrieve get/post/cookie vars etc, then you can
clean it however you want and also build in the isset() stuff there so
it returns '' or false, etc... and you don't have all kinds of isset()
or !empty() calls in your main code.

So build some general purpose functions or methods that scrub input and
prep output and try and get it to handle as many cases as possible.
Then use those functions.

-- 
Thanks!
-Shawn
http://www.spidean.com

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



[PHP] pear mdb2 and null

2009-04-11 Thread Michael A. Peters

I've run into a small issue with mdb2.

I have a mysql database with a field set to longtext not null.

inserting  into that field works just dandy when using the mysql_ 
functions.


However, when using mdb2 - it converts  to NULL which is NOT what I 
want to have happen, and the result is that the execute() fails because 
the database table does not accept NULL for that field.


Why does mdb2 turn  into NULL for a text type when MySQL knows there 
is a difference? How do I suppress that?


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



Re: [PHP] How about a saveXHTML for the DOM?

2009-04-11 Thread Michael A. Peters

Raymond Irving wrote:


If I remove the \r from the file using preg_replace() then it shows up just 
fine. I was just wondering if there was a way to suppress the \r in the xml 
output.

Another thing that I've observed while looking at your code is that it only 
works best for dynamic web pages. It appears that it would not work well when 
using page caching or page templates.

I really think having a function that generates xhtml (html compatible) output, 
would really eliminate all these workarounds that we will have to do in order 
to get the page to render inside popular web browsers.

A lot of developers produce xhtml web pages that are html 4 compatible, so that 
they can be rendered in browsers that only supports html rendering. This is 
something that I think the PHP DOM should be able to support with ease.




If you want to send the same page for everybody than use html 4.01 (or 
html 5 when it is ready) and the saveHTML() function.


The only reason I don't do that is because I wish html would go away, so 
I generally send valid xhtml (header and all) and only provide the html 
as a fall back for inferior browsers.


With respect to templating systems, I don't use them but if you have a 
DOMDocument orientated template system, I don't see why it couldn't do 
the same thing - as far as the DOM used to generate xhtml (via 
saveXML()) or html (via saveHTML()) - the only difference is the DTD and 
the fact that xhtml sometimes uses namespaced attributes (which may get 
stripped with saveHTML() anyway)


That's the beauty IMHO of DOMDocument - virtually identical data in the 
DOM can produce valid html or xhtml - as long as you aren't using xhtml 
only extensions (like MathML).


So it should work beautifully with a templating system, as long as the 
templating system is built for DOMDocument consumption.


I think there are a few.

How well they work with caching I don't know.

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



Re: [PHP] How about a saveXHTML for the DOM?

2009-04-11 Thread Michael A. Peters

Michael A. Peters wrote:



With respect to templating systems, I don't use them but if you have a 
DOMDocument orientated template system, I don't see why it couldn't do 
the same thing - 


As an experiment, I took one of my pages that was a little sluggish due 
to lots of database calls (sluggish on my home machine anyway) - since 
the database content rarely changes for the data presented, I made a 
page I can grab nightly in cron that spits out just the main content div 
where all the DB calls are made.


-=-
$cached = 'species_cache.php';
$SL = file_get_contents($cached);
$SDOM = new DOMDocument(1.0,UTF-8);
$SDOM-loadXML($SL);
$elements = $SDOM-getElementsByTagName(div);
$imported_div = $elements-item(0);
$contentDiv = $myxhtml-importNode($imported_div,true);
-=-

species_cache.php

is just a text file with a div and all it's children.

Sped up the page considerably on my home machine, and works spledidly 
regardless of whether or not I am sending it as html or xhtml.


So I think my technique would work with template systems.

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