php-general Digest 30 Jan 2010 12:20:43 -0000 Issue 6566

Topics (messages 301666 through 301688):

Re: In need of PHP to JS collapsable array printing routine?
        301666 by: TG
        301672 by: Ashley Sheridan
        301680 by: Jochem Maas

how do I use php://memory?
        301667 by: Mari Masuda
        301668 by: Nathan Nobbe
        301669 by: Jochem Maas
        301670 by: Shawn McKenzie
        301673 by: Eric Lee
        301681 by: Shawn McKenzie
        301682 by: Daniel P. Brown
        301683 by: Mari Masuda
        301684 by: Mari Masuda

Re: Ideas please -- take query results --- output to image
        301671 by: Ashley Sheridan

Sessions across subdomains
        301674 by: Ben Miller
        301679 by: Jochem Maas

Re: Creating an Entire .html page with PHP
        301675 by: clancy_1.cybec.com.au
        301676 by: Ashley Sheridan
        301677 by: clancy_1.cybec.com.au

Re: Pointers For Newbies, Reminders For Oldies
        301678 by: clancy_1.cybec.com.au

Re: Speed of sending email .. can I put them in a queue rather than wait?
        301685 by: Manuel Lemos
        301686 by: Per Jessen

File Upload
        301687 by: Ali Reza Sajedi
        301688 by: Kim Madsen

Administrivia:

To subscribe to the digest, e-mail:
        [email protected]

To unsubscribe from the digest, e-mail:
        [email protected]

To post to the list, e-mail:
        [email protected]


----------------------------------------------------------------------
--- Begin Message ---
Take a look at the Firebug addon for Firefox and another addon called 
"FirePHP" or "FireConsole" (the new name coming soon).  It lets you 
output PHP debugging data to HTTP headers that show up in your Firebug 
console.  I believe it supports collapsable tree type output.

-TG

----- Original Message -----
From: "Daevid Vincent" <[email protected]>
To: <[email protected]>
Date: Fri, 29 Jan 2010 15:54:33 -0800
Subject: [PHP] In need of PHP to JS collapsable array printing routine?

> I'm  wondering if anyone has a PHP debug-type routine that will take a PHP
> array and output it to the web page, but make all the dimensions of the
> array collapsable, ideally showing each sub-key (or index) as the name to
> click to expand it again.
> 
> I'm dealing with some rather huge datasets in multi-dimensional hashes and
> printing them out with a beautified print_r() is just not cutting it
> anymore. I need to collapse them down to wrap my head around them. Some of
> them have 6 or more dimensions!
> 
> I use jQuery for JS if that helps (in case your routine requires that 
too).
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 

--- End Message ---
--- Begin Message ---
On Fri, 2010-01-29 at 15:54 -0800, Daevid Vincent wrote:

> I'm  wondering if anyone has a PHP debug-type routine that will take a PHP
> array and output it to the web page, but make all the dimensions of the
> array collapsable, ideally showing each sub-key (or index) as the name to
> click to expand it again.
> 
> I'm dealing with some rather huge datasets in multi-dimensional hashes and
> printing them out with a beautified print_r() is just not cutting it
> anymore. I need to collapse them down to wrap my head around them. Some of
> them have 6 or more dimensions!
> 
> I use jQuery for JS if that helps (in case your routine requires that too).
> 
> 


I know it's not quite what you want, but what about copying and pasting
the output from the view source to a more advanced text editor like Kate
or Notepad++. They both support code-folding, and allow you to minimise
blocks of code at points in the text, usually where you have opened
brackets, etc. This also comes in handy when you're developing too.

Thanks,
Ash
http://www.ashleysheridan.co.uk



--- End Message ---
--- Begin Message ---
Op 1/30/10 12:54 AM, Daevid Vincent schreef:
> I'm  wondering if anyone has a PHP debug-type routine that will take a PHP
> array and output it to the web page, but make all the dimensions of the
> array collapsable, ideally showing each sub-key (or index) as the name to
> click to expand it again.
> 
> I'm dealing with some rather huge datasets in multi-dimensional hashes and
> printing them out with a beautified print_r() is just not cutting it
> anymore. I need to collapse them down to wrap my head around them. Some of
> them have 6 or more dimensions!
> 
> I use jQuery for JS if that helps (in case your routine requires that too).

what everyone else said ... additionally check out the recent archives for
posts by Rene Veerman ... his current pet project seems to be something that
would be of interest you.

> 


--- End Message ---
--- Begin Message ---
Hello,

I have a function that uses tidy to attempt to clean up a bunch of crappy HTML 
that I inherited.  In order to use tidy, I write the crappy HTML to a temporary 
file on disk, run tidy, and extract and return the clean(er) HTML.  The program 
itself works fine but with all of the disk access, it runs quite slowly.  I saw 
on this page (http://www.php.net/manual/en/wrappers.php.php) that I could write 
to memory by using php://memory.  Unfortunately, I could not quite get it to 
work.  The problem is that in the below function, the code within the [[[if 
(file_exists($dirty_file_path))]]] does not get run if I change 
[[[$dirty_file_path]]] to "php://memory".  Has anyone ever successfully used 
php://memory before?  If so, what can I do to use it in my code?  Thank you.


//==========================================================
function cleanUpHtml($dirty_html, $enclose_text=true) {

        $parent_dir = "/filesWrittenFromPHP/";
        $now = time();
        $random = rand();
        
        //save dirty html to a file so tidy can process it
        $dirty_file_path = $parent_dir . "dirty" . $now . "-" . $random . 
".txt";
        $dirty_handle = fopen($dirty_file_path, "w");
        fwrite($dirty_handle, $dirty_html);
        fclose($dirty_handle);

        $cleaned_html = "";
        $start = 0;
        $end = 0;

        if (file_exists($dirty_file_path)) {
                exec("/usr/local/bin/tidy -miq -wrap 0 -asxhtml --doctype 
strict --preserve-entities yes --css-prefix \"tidy\" --tidy-mark no 
--char-encoding utf8 --drop-proprietary-attributes yes  --fix-uri yes " . 
($enclose_text ? "--enclose-text yes " : "") . $dirty_file_path . " 2> 
/dev/null");

                $tidied_html = file_get_contents($dirty_file_path);
                
                $start = strpos($tidied_html, "<body>") + 6;
                $end = strpos($tidied_html, "</body>") - 1;
                
                $cleaned_html = trim(substr($tidied_html, $start, ($end - 
$start)));
        }
        
        unlink($dirty_file_path);


        return $cleaned_html;
}
//==========================================================


--- End Message ---
--- Begin Message ---
On Fri, Jan 29, 2010 at 5:35 PM, Mari Masuda <[email protected]>wrote:

> Hello,
>
> I have a function that uses tidy to attempt to clean up a bunch of crappy
> HTML that I inherited.  In order to use tidy, I write the crappy HTML to a
> temporary file on disk, run tidy, and extract and return the clean(er) HTML.
>  The program itself works fine but with all of the disk access, it runs
> quite slowly.


why read from disk in the first place?

http://us3.php.net/manual/en/tidy.parsestring.php

-nathan

--- End Message ---
--- Begin Message ---
Op 1/30/10 1:35 AM, Mari Masuda schreef:
> Hello,
> 
> I have a function that uses tidy to attempt to clean up a bunch of crappy 
> HTML that I inherited.  In order to use tidy, I write the crappy HTML to a 
> temporary file on disk, run tidy, and extract and return the clean(er) HTML.  
> The program itself works fine but with all of the disk access, it runs quite 
> slowly.  I saw on this page (http://www.php.net/manual/en/wrappers.php.php) 
> that I could write to memory by using php://memory.  Unfortunately, I could 
> not quite get it to work.  The problem is that in the below function, the 
> code within the [[[if (file_exists($dirty_file_path))]]] does not get run if 
> I change [[[$dirty_file_path]]] to "php://memory".  Has anyone ever 
> successfully used php://memory before?  If so, what can I do to use it in my 
> code?  Thank you.

what does it matter that it runs slowly, run it once and be done with it?
alternatively use the php tidy extension and avoid the file system and shelling 
out altogether.

actually I'd imagine shelling out from a webserver process is the bottle neck 
and not saving/reading
from the file system.

lastly I don't suppose you've heard of /dev/shm ?

and, er, no, I don't have experience with php://memory but you might try 
searching for
other people's code:

        
http://www.google.com/codesearch?q=php%3A%2F%2Fmemory&hl=en&btnG=Search+Code

> //==========================================================
> function cleanUpHtml($dirty_html, $enclose_text=true) {
> 
>       $parent_dir = "/filesWrittenFromPHP/";
>       $now = time();
>       $random = rand();
>       
>       //save dirty html to a file so tidy can process it
>       $dirty_file_path = $parent_dir . "dirty" . $now . "-" . $random . 
> ".txt";
>       $dirty_handle = fopen($dirty_file_path, "w");
>       fwrite($dirty_handle, $dirty_html);
>       fclose($dirty_handle);
> 
>       $cleaned_html = "";
>       $start = 0;
>       $end = 0;
> 
>       if (file_exists($dirty_file_path)) {
>               exec("/usr/local/bin/tidy -miq -wrap 0 -asxhtml --doctype 
> strict --preserve-entities yes --css-prefix \"tidy\" --tidy-mark no 
> --char-encoding utf8 --drop-proprietary-attributes yes  --fix-uri yes " . 
> ($enclose_text ? "--enclose-text yes " : "") . $dirty_file_path . " 2> 
> /dev/null");
> 
>               $tidied_html = file_get_contents($dirty_file_path);
>               
>               $start = strpos($tidied_html, "<body>") + 6;
>               $end = strpos($tidied_html, "</body>") - 1;
>               
>               $cleaned_html = trim(substr($tidied_html, $start, ($end - 
> $start)));
>       }
>       
>       unlink($dirty_file_path);
> 
> 
>       return $cleaned_html;
> }
> //==========================================================
> 
> 


--- End Message ---
--- Begin Message ---
Mari Masuda wrote:

> Has anyone ever successfully used php://memory before?  If so, what
> can I do to use it in my code?  Thank you.

No, but I was intrigued to try it, so I tested this:

$text = 'Some text.';
file_put_contents('php://memory', $text);
echo file_get_contents('php://memory');

And it returned nothing.  The docs suck on this and it apparently
doesn't work.  I see others use it with fopen(), but there is no mention
of which file functions it works with and which it doesn't.

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

--- End Message ---
--- Begin Message ---
On Sat, Jan 30, 2010 at 9:00 AM, Shawn McKenzie <[email protected]>wrote:

> Mari Masuda wrote:
>
> > Has anyone ever successfully used php://memory before?  If so, what
> > can I do to use it in my code?  Thank you.
>
> No, but I was intrigued to try it, so I tested this:
>
> $text = 'Some text.';
> file_put_contents('php://memory', $text);
> echo file_get_contents('php://memory');
>
> And it returned nothing.  The docs suck on this and it apparently
> doesn't work.  I see others use it with fopen(), but there is no mention
> of which file functions it works with and which it doesn't.
>
>

Shawn

I did a sample test from the manual with fopen like this,


<?php

$fp = fopen('php://memory', 'r+');

if ($fp)
{
    fputs($fp, "line 1\n");
}

rewind($fp);
echo stream_get_contents($fp);

?>

console output

F:\wc\trunk>php -f m.php
line 1



Regards,
Eric,

--
> Thanks!
> -Shawn
> http://www.spidean.com
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

--- End Message ---
--- Begin Message ---
Eric Lee wrote:
> On Sat, Jan 30, 2010 at 9:00 AM, Shawn McKenzie <[email protected]>wrote:
> 
>> Mari Masuda wrote:
>>
>>> Has anyone ever successfully used php://memory before?  If so, what
>>> can I do to use it in my code?  Thank you.
>> No, but I was intrigued to try it, so I tested this:
>>
>> $text = 'Some text.';
>> file_put_contents('php://memory', $text);
>> echo file_get_contents('php://memory');
>>
>> And it returned nothing.  The docs suck on this and it apparently
>> doesn't work.  I see others use it with fopen(), but there is no mention
>> of which file functions it works with and which it doesn't.
>>
>>
> 
> Shawn
> 
> I did a sample test from the manual with fopen like this,
> 
> 
> <?php
> 
> $fp = fopen('php://memory', 'r+');
> 
> if ($fp)
> {
>     fputs($fp, "line 1\n");
> }
> 
> rewind($fp);
> echo stream_get_contents($fp);
> 
> ?>
> 
> console output
> 
> F:\wc\trunk>php -f m.php
> line 1
> 
> 
> 
> Regards,
> Eric,

So maybe it only works with an open file/stream resource? Hard to tell
with no docs.


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

--- End Message ---
--- Begin Message ---
(Typing from the DROID, so forgive the top-posting.)

Shawn, would you take a few moments to submit this as a bug at
http://bugs.php.net/? I know you well enough that, if you say the docs suck,
they probably do.

On Jan 29, 2010 10:47 PM, "Shawn McKenzie" <[email protected]> wrote:

Eric Lee wrote:
> On Sat, Jan 30, 2010 at 9:00 AM, Shawn McKenzie <[email protected]
>wrote:
>
>>...
So maybe it only works with an open file/stream resource? Hard to tell
with no docs.


--

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

-- 
PHP General Mailing List (http://www.php.net/)
To unsubsc...

--- End Message ---
--- Begin Message ---
On Jan 29, 2010, at 4:38 PM, Nathan Nobbe wrote:

> On Fri, Jan 29, 2010 at 5:35 PM, Mari Masuda <[email protected]> wrote:
> Hello,
> 
> I have a function that uses tidy to attempt to clean up a bunch of crappy 
> HTML that I inherited.  In order to use tidy, I write the crappy HTML to a 
> temporary file on disk, run tidy, and extract and return the clean(er) HTML.  
> The program itself works fine but with all of the disk access, it runs quite 
> slowly.
> 
> why read from disk in the first place?
> 
> http://us3.php.net/manual/en/tidy.parsestring.php
> 
> -nathan 

Thank you, this looks like exactly what I need.  Unfortunately I cannot get it 
to work on my machine.  I recompiled PHP with --with-tidy=/usr/local and this 
is the version and modules in use:

[Fri Jan 29 22:50:41] ~: php -vPHP 5.2.12 (cli) (built: Jan 29 2010 22:35:24) 
Copyright (c) 1997-2009 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2009 Zend Technologies
[Fri Jan 29 22:52:30] ~: php -m
[PHP Modules]
ctype
date
dom
filter
gd
hash
iconv
json
libxml
mbstring
mysql
mysqli
pcre
PDO
pdo_mysql
pdo_sqlite
posix
Reflection
session
SimpleXML
SPL
SQLite
standard
tidy
tokenizer
xml
xmlreader
xmlwriter
zlib

[Zend Modules]

[Fri Jan 29 22:52:34] ~: 


When I run this test code
=====================
<?php
$html = 
"<html><head><title>blah</title></head><body><p>hello</p></body></html>";
$config = array('indent' => true,
                'wrap' => '0');

// Tidy
$tidy = new tidy();
var_dump($tidy);
$tidy->parseString($html, $config, 'utf8');
var_dump($tidy);
$tidy->cleanRepair();
var_dump($tidy);
echo tidy_get_output($tidy);
var_dump($tidy);
?>
=====================

I get this output:
=====================
object(tidy)#1 (2) {
  ["errorBuffer"]=>
  NULL
  ["value"]=>
  NULL
}
object(tidy)#1 (2) {
  ["errorBuffer"]=>
  NULL
  ["value"]=>
  NULL
}
object(tidy)#1 (2) {
  ["errorBuffer"]=>
  NULL
  ["value"]=>
  NULL
}
object(tidy)#1 (2) {
  ["errorBuffer"]=>
  NULL
  ["value"]=>
  NULL
}
====================

I have no clue what I'm doing wrong...

Mari

--- End Message ---
--- Begin Message ---
On Jan 29, 2010, at 10:57 PM, Mari Masuda wrote:

> 
> On Jan 29, 2010, at 4:38 PM, Nathan Nobbe wrote:
> 
>> On Fri, Jan 29, 2010 at 5:35 PM, Mari Masuda <[email protected]> 
>> wrote:
>> Hello,
>> 
>> I have a function that uses tidy to attempt to clean up a bunch of crappy 
>> HTML that I inherited.  In order to use tidy, I write the crappy HTML to a 
>> temporary file on disk, run tidy, and extract and return the clean(er) HTML. 
>>  The program itself works fine but with all of the disk access, it runs 
>> quite slowly.
>> 
>> why read from disk in the first place?
>> 
>> http://us3.php.net/manual/en/tidy.parsestring.php
>> 
>> -nathan 
> 
> Thank you, this looks like exactly what I need.  Unfortunately I cannot get 
> it to work on my machine.

[snip]

So I figured it out... I was using the wrong command to compile libtidy.  (I am 
not a *nix geek so I had no idea I was messing it up.)  To get it working, I 
followed the instructions I found here: 
http://www.php.net/manual/en/ref.tidy.php#64281

My setup is slightly different from the person who wrote the directions in that 
I am running OS X 10.6.2 and PHP 5.2.12.  However, the only difference between 
the instructions I followed and what I actually had to do is that the line to 
comment out for me was line 525 instead of 508.  (The actual line is: typedef 
unsigned long ulong;)

Thank you everyone for your help!

--- End Message ---
--- Begin Message ---
On Fri, 2010-01-29 at 22:33 +0100, Rene Veerman wrote:

> other idea: <iframe>s, and plain old links.
> 
> 
> On Fri, Jan 29, 2010 at 10:32 PM, Rene Veerman <[email protected]> wrote:
> > flash(develop.org) perhaps? or does that also fall under their
> > no-active-x policy?
> >
> > On Fri, Jan 29, 2010 at 9:17 PM, Haig Davis <[email protected]> wrote:
> >> Good Day All,
> >>
> >> The headscratcher of the day for me is as follows:
> >>
> >> I'm busy designing a scheduling page in a table form (actually series of
> >> floating css divs) showing days of week across/ rooms down. thats the easy
> >> part and bookings in each cell. I know I can take the results of a query
> >> call it expanded booking details start_ob output to html save to file/
> >> image etc, that way on mouse over the date I can use CSS to explode the
> >> image file displaying the results.  Here's my question.
> >>
> >> Any hints can I do all of this on the fly yet not display the HTML query
> >> results that are created until mouse over ..... I'm sure this is easy with
> >> javascript my problem is my client does has disabled javascript/ active X
> >> scripts.
> >>
> >> Been scratching my head for a while and it's starting to bleed.
> >>
> >> Thanks and have a great weekend.
> >>
> >> Cheers
> >>
> >> Haig
> >>
> >
> 


Quite easy to do with some CSS.

<a href="#" class="details">
    regular content
    <div class="details">hidden until mouse overed</div>
</a>

And the CSS would be something like:

a.details
{
    position: relative;
}
a.details div.details
{
    position: absolute;
    top: 0px;
    left: 0px;
    display: none;
}
a:hover div.details
{
    display: block;
}

This is a simplified example, but works without Javascript, and if the
browser doesn't support CSS, the hidden details are just displayed
normally, which is the best fail method I think.

Thanks,
Ash
http://www.ashleysheridan.co.uk



--- End Message ---
--- Begin Message ---
Hi, I've always thought that session data was subdomain specific and would
not carry over between http://www.mydomain.com and
https://secure.mydomain.com, but it seems to be working for me now.  Can I
rely on this and post from http://www.mydomain.com to
https://secure.mydomain.com and simply pass a hidden input containing
PHPSESSID, or do I need to pass each key=>value pair that _SESSION contains
at www.  and reset them as _SESSION vars at secure.
<https://secure.mydomain.com> ? 

 

Thanks in advance,

Ben


--- End Message ---
--- Begin Message ---
Op 1/30/10 2:25 AM, Ben Miller schreef:
> Hi, I've always thought that session data was subdomain specific and would
> not carry over between http://www.mydomain.com and
> https://secure.mydomain.com, but it seems to be working for me now.  Can I
> rely on this and post from http://www.mydomain.com to
> https://secure.mydomain.com and simply pass a hidden input containing
> PHPSESSID, or do I need to pass each key=>value pair that _SESSION contains
> at www.  and reset them as _SESSION vars at secure.
> <https://secure.mydomain.com> ? 
> 

1. cookies are shared automatically on SUB domains, so if you set your cookie 
domain
to example.com it will be available at both www.example.com and 
secure.example.com

2. cookies can have a HTTPS flag set which means they will not be shared with 
non-HTTPS
connections.

3. DONT put the contents of $_SESSION on the wire. (given the question you're 
asking I'd
hazard a guess you don't have the skills to sufficiently

4. google/read/search/learn about the security implications of sharing a cookie 
between
HTTPS and non-HTTPS domains.

5. session_regenerate_id() - I would use this if you intend to pass session ids 
around,
although it will probably give you a stack of problems in terms of usability 
(e.g. back button usage),
actually I'd use it any time you log someone in or out or have a user perform a 
particularly
sensitive action.

6. the $_SESSION will only be available on both sites if they are both on the 
same server
and running with the same session ini settings (i.e. session save path, session 
name) - different
servers could obviously be using a shared filesystem or an alternative session 
storage (e.g.
memcached or database server).

7. consider not sharing the session - instead pass just the data that you need 
(e.g. shopping
basket contents etc) and either including a hash of the data (which uses a 
secret string that
is not included in the form/url/etc but that both servers/sites know about 
AND/OR using 2-way
public key encryption on the data that you pass in between the servers/sites

personally for higher end commercial sites I prefer to just to put everything 
on HTTPS
solving all potential issues with sharing a cookie or data between nonHTTPS and 
HTTPS sites,
and everything directly related ... the cost being extra overhead per request - 
but hardware
is cheap and security is difficult to get exactly right.

the biggest names on the web have [had] security loophopes/problems related to 
these issues, and they
generally have tons of man power and some very clever/knowledgable people on 
their teams - which is to say:
your chance (and mine for that matter) of not making any mistakes on this front 
are slimmer than theirs.

> Thanks in advance,
> 
> Ben
> 
> 


--- End Message ---
--- Begin Message ---
On Thu, 28 Jan 2010 13:39:31 -0800, [email protected] ("Michael A. Peters") wrote:

>[email protected] wrote:
>> On Thu, 28 Jan 2010 21:10:42 +0100, [email protected] (Rene Veerman) wrote:
>> 
>>> On Thu, Jan 28, 2010 at 12:31 AM,  <[email protected]> wrote:
>>>> On Wed, 27 Jan 2010 10:21:00 -0800, [email protected] (dealtek) wrote:
>>>> Opening tables, etc, wrongly generally messes the page up completely, but
>>>> forgetting to close them again often has no affect no visible effect at 
>>>> all -- until you
>>>> make some innocent change and everything goes haywire!
>>> whenever i write an opening tag, i immediately write the closing tag
>>> next, then cursor back to fill it in.
>> 
>> Not so easy when you are using PHP to generate a complex layout!
>> 
>> 
>
>Use DOMDocument.
>Then you don't have to worry about closing the tags ;)

Ohhh?  The index page of the manual has 110 lines of totally meaningless 
entries, and the
introduction doesn't open. I haven't the faintest idea what it's all about, but 
I very
much doubt if it would mean anything to the original writer.


--- End Message ---
--- Begin Message ---
On Sat, 2010-01-30 at 12:34 +1100, [email protected] wrote:

> On Thu, 28 Jan 2010 13:39:31 -0800, [email protected] ("Michael A. Peters") 
> wrote:
> 
> >[email protected] wrote:
> >> On Thu, 28 Jan 2010 21:10:42 +0100, [email protected] (Rene Veerman) 
> >> wrote:
> >> 
> >>> On Thu, Jan 28, 2010 at 12:31 AM,  <[email protected]> wrote:
> >>>> On Wed, 27 Jan 2010 10:21:00 -0800, [email protected] (dealtek) wrote:
> >>>> Opening tables, etc, wrongly generally messes the page up completely, but
> >>>> forgetting to close them again often has no affect no visible effect at 
> >>>> all -- until you
> >>>> make some innocent change and everything goes haywire!
> >>> whenever i write an opening tag, i immediately write the closing tag
> >>> next, then cursor back to fill it in.
> >> 
> >> Not so easy when you are using PHP to generate a complex layout!
> >> 
> >> 
> >
> >Use DOMDocument.
> >Then you don't have to worry about closing the tags ;)
> 
> Ohhh?  The index page of the manual has 110 lines of totally meaningless 
> entries, and the
> introduction doesn't open. I haven't the faintest idea what it's all about, 
> but I very
> much doubt if it would mean anything to the original writer.
> 
> 


I've never used DomDoument to create an HTML page, and I probably never
will. I also don't have much of a problem with creating decent html code
that validates either.

Thanks,
Ash
http://www.ashleysheridan.co.uk



--- End Message ---
--- Begin Message ---
On Thu, 28 Jan 2010 16:23:05 -0500, [email protected] (Paul M Foster) 
wrote:

>On Fri, Jan 29, 2010 at 08:17:34AM +1100, [email protected] wrote:
>
>> On Thu, 28 Jan 2010 21:10:42 +0100, [email protected] (Rene Veerman) wrote:
>> 
>> >On Thu, Jan 28, 2010 at 12:31 AM,  <[email protected]> wrote:
>> >> On Wed, 27 Jan 2010 10:21:00 -0800, [email protected] (dealtek) wrote:
>> >>Opening tables, etc, wrongly generally messes the page up completely, but
>> >> forgetting to close them again often has no affect no visible effect
>> at all -- until you
>> >> make some innocent change and everything goes haywire!
>> >
>> >whenever i write an opening tag, i immediately write the closing tag
>> >next, then cursor back to fill it in.
>> 
>> Not so easy when you are using PHP to generate a complex layout!
>
>Use heredocs to do it. Then you can generate the layout in PHP and still
>do what [email protected] said.

I don't think heredocs is relevant. The original writer wanted to save the HTML 
output of
a working page to a file, whereas (I think!) heredocs are involved with getting 
messy
stuff into PHP. 

I still think that simply capturing the page from the browser is the simplest 
solution for
the original question, but if you want a more elegant one see:

http://codeutopia.net/blog/2007/10/03/how-to-easily-redirect-php-output-to-a-file/

The writer appears to know what he's talking about, and I am pleased to have 
found this,
as I have often wanted to to redirect PHP output to a file.


--- End Message ---
--- Begin Message ---
On Thu, 28 Jan 2010 10:02:56 -0500, [email protected] (Robert Cummings) 
wrote:


>I don't know what you guys are doing wrong but the following should be 
>the correct behaviour:
>
><?php
>
>function get_memory( $init=false )
>{
>     static $base = null;
>     if( $base === null || $init )
>     {
>         $base = memory_get_usage();
>     }
>
>     return memory_get_usage() - $base;
>}
>
>function simple_access( $data )
>{
>     $foo = $data[100];
>     echo 'Memory: '.get_memory().' (simple access)'."\n";
>}
>
>function foreach_value_access( $data )
>{
>     foreach( $data as $value )
>     {
>         $foo = $value;
>         break;
>     }
>     echo 'Memory: '.get_memory().' (foreach value access)'."\n";
>}
>
>function foreach_key_access( $data )
>{
>     foreach( $data as $key => $value )
>     {
>         $foo = $key;
>         $foo = $value;
>         break;
>     }
>     echo 'Memory: '.get_memory().' (foreach key/value access)'."\n";
>}
>
>function modify_single_access( $data )
>{
>     $data[100] = str_repeat( '@', 10000 );
>     echo 'Memory: '.get_memory().' (modify single access)'."\n";
>}
>
>function modify_all_access( $data )
>{
>     for( $i = 0; $i < 1000; $i++ )
>     {
>         $data[$i] = str_repeat( '@', 10000 );
>     }
>
>     echo 'Memory: '.get_memory().' (modify all access)'."\n";
>}
>
>
>get_memory( true );
>
>$data = array();
>for( $i = 0; $i < 1000; $i++ )
>{
>     $data[$i] = str_repeat( '#', 10000 );
>}
>
>echo 'Memory: '.get_memory().' (data initialized)'."\n";
>
>simple_access( $data );
>foreach_value_access( $data );
>foreach_key_access( $data );
>modify_single_access( $data );
>modify_all_access( $data );
>
>?>
>
>I get the following output (PHP 5.2.11 from command-line):
>
>     Memory: 10160768 (data initialized)
>     Memory: 10161008 (simple access)
>     Memory: 10161104 (foreach value access)
>     Memory: 10161240 (foreach key/value access)
>     Memory: 10267312 (modify single access)
>     Memory: 20321576 (modify all access)
>
>I don't double up on memory consumption until I force the write onto 
>every element... this is expected because internally every array element 
>is individually subject to the Copy-On-Write (COW) principle since each 
>element is internally stored as a zval just like the array itself.

Thanks for this.  I was just revising a bit of code to insert some extra 
entries into an
array. Previously I had opened a new array, copied the data up to the insertion 
point into
it, put in the new entry, then copied the tail, then renamed the new array. 
After reading
this, I realise the correct procedure was to copy the existing data into a 
temporary
array, insert the new entry in the existing array, and then copy the tail from 
the copy
back into the working data.

This way only the data in the tail actually has to be copied, rather than the 
whole array.

--- End Message ---
--- Begin Message ---
Hello,

on 01/27/2010 12:07 AM Eric Lee said the following:
> Hi, all
> 
> I'am doubted about installing a local mail server for just low volume
> mailing.
> May I ask all yours professional what do you think about it ?

I do not use nor recommend Windows for delivering messages to many
recipients, but if you are stuck with it, maybe you can use Microsoft
Exchange in the same machine where PHP is running, you can drop the
messages in the mail queue pickup directory to avoid waiting for the
mail server to process them.

-- 

Regards,
Manuel Lemos

Find and post PHP jobs
http://www.phpclasses.org/jobs/

PHP Classes - Free ready to use OOP components written in PHP
http://www.phpclasses.org/

--- End Message ---
--- Begin Message ---
Angus Mann wrote:

> The number of emails sent is very small. Each one is only sent after a
> user fills out a form and presses send.
> 
> But there is a noticable lag of about 5 or sometimes 10 seconds after
> pressing "send" before the user sees the "Mail sent" page. I presume
> the reason for the lag is the time spent logging on and off a remote
> POP, then SMTP server, transferring the data etc.
> 
> It would be better if this happened in the background - that is, the
> user could get on with doing his next task while the emails sat in a
> queue in the backgorund, being lined up and sent without PHP waiting
> for the process to finish.

sendmail is your answer. 


/Per

-- 
Per Jessen, Zürich (0.6°C)


--- End Message ---
--- Begin Message ---
Hello,

When uploading a file the variable $_FILES['userfile']['tmp_name'] is not set and when debugging I get the following error although /tmp folder exists and the permissions are set to 777:

$_FILES['userfile']['error'] = 6

which says

UPLOAD_ERR_NO_TMP_DIR
Value: 6; Missing a temporary folder. Introduced in PHP 4.3.10 and PHP 5.0.3.

Has anyone encountered such a problem or has a clue as to what the cause could be?

Thank you.

Kind regards

Ali
--- End Message ---
--- Begin Message ---
Ali Reza Sajedi wrote on 30/01/2010 12:27:

UPLOAD_ERR_NO_TMP_DIR
Value: 6; Missing a temporary folder. Introduced in PHP 4.3.10 and PHP 5.0.3.

Has anyone encountered such a problem or has a clue as to what the cause could be?

What does "print phpinfo()"; tell you about the upload_tmp_dir?

--
Kind regards
Kim Emax - masterminds.dk

--- End Message ---

Reply via email to