php-general Digest 14 May 2009 21:43:09 -0000 Issue 6121

Topics (messages 292563 through 292593):

Re: Cannot output the same data from text file in PHP
        292563 by: Peter Ford
        292564 by: Jan G.B.
        292569 by: Mike Roberts
        292570 by: Nathan Rixham
        292579 by: Ashley Sheridan
        292580 by: Andrew Ballard
        292581 by: Ashley Sheridan
        292582 by: Mike Roberts
        292583 by: Ashley Sheridan
        292587 by: Paul M Foster
        292589 by: Andrew Ballard
        292591 by: Ashley Sheridan

Re: Sending SMS through website
        292565 by: Select Performers

When is __destruct called on an object in $_SESSION ?
        292566 by: Peter Ford
        292567 by: Stuart
        292568 by: Peter Ford

suggestion required
        292571 by: Pravinc

where & what
        292572 by: PJ

Re: where & what-SOLVED
        292573 by: PJ

include file syntax
        292574 by: PJ
        292576 by: Shawn McKenzie

php & html integration
        292575 by: PJ
        292577 by: Shawn McKenzie
        292578 by: Tom Worster
        292584 by: tedd
        292588 by: Paul M Foster

Software to read/write Excel to CD?
        292585 by: Skip Evans
        292590 by: Paul M Foster
        292592 by: Ashley Sheridan

php ssl connection timeout issue
        292586 by: Jerry Zhao
        292593 by: Shawn McKenzie

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


----------------------------------------------------------------------
--- Begin Message ---
Moses wrote:
> Hi Folks,
> 
> I have a written a script in PHP which outputs the result from a text file.
> The PHP script is as follows:
> 
> <?php
> $alldata = file("result.txt");
> echo "<table><tr><td>";
> foreach($alldata as $line_num => $line) {
> echo $line."<br>";
> }
> echo"</td></tr></table>";
> ?>
> 
> I have attached the result.txt file. However the output of the script is as
> follows:
> 
> 
> Query: 1 atggcaatcgtttcagcagaaaaattcgtaattcgagctcgcccggggatcgatcctcta 60
> ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
> Sbjct: 1 atggcaatcgtttcagcagaaaaattcgtaattcgagctcgcccggggatcgatcctcta 60
> 
> which is not exactly  as in the result.txt file in that the pipelines
> are displaced.
> 
> Any pointer to this problem shall be appreciated. Thanking you in advance.
> 
> Moses
> 

Not a PHP problem, but a HTML problem:
First, HTML compresses white space into just one space, so all of those leading
spaces on line 2 are lost.
Second, you are (probably) displaying using a proportionally-spaced font, so the
narrow pipeline characters take up less width than the letters.

So you need something like:
<?php
$alldata = file("result.txt");
echo "<table><tr><td style='white-space: pre; font-family: monospace;'>";
foreach($alldata as $line_num => $line)
{
    echo $line."\n";
}
echo"</td></tr></table>";
?>


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

--- End Message ---
--- Begin Message ---
You could even make it shorter, if you don't need the line numbers anyway:
<pre>
 <?
  echo nl2br(file_get_contents('file.txt'));
 ?>
</pre>

2009/5/14 Peter Ford <p...@justcroft.com>:
> Moses wrote:
>> Hi Folks,
>>
>> I have a written a script in PHP which outputs the result from a text file.
>> The PHP script is as follows:
>>
>> <?php
>> $alldata = file("result.txt");
>> echo "<table><tr><td>";
>> foreach($alldata as $line_num => $line) {
>> echo $line."<br>";
>> }
>> echo"</td></tr></table>";
>> ?>
>>
>> I have attached the result.txt file. However the output of the script is as
>> follows:
>>
>>
>> Query: 1 atggcaatcgtttcagcagaaaaattcgtaattcgagctcgcccggggatcgatcctcta 60
>> ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
>> Sbjct: 1 atggcaatcgtttcagcagaaaaattcgtaattcgagctcgcccggggatcgatcctcta 60
>>
>> which is not exactly  as in the result.txt file in that the pipelines
>> are displaced.
>>
>> Any pointer to this problem shall be appreciated. Thanking you in advance.
>>
>> Moses
>>
>
> Not a PHP problem, but a HTML problem:
> First, HTML compresses white space into just one space, so all of those 
> leading
> spaces on line 2 are lost.
> Second, you are (probably) displaying using a proportionally-spaced font, so 
> the
> narrow pipeline characters take up less width than the letters.
>
> So you need something like:
> <?php
> $alldata = file("result.txt");
> echo "<table><tr><td style='white-space: pre; font-family: monospace;'>";
> foreach($alldata as $line_num => $line)
> {
>    echo $line."\n";
> }
> echo"</td></tr></table>";
> ?>
>
>
> --
> Peter Ford                              phone: 01580 893333
> 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
>
>

--- End Message ---
--- Begin Message ---
Is there a moderator or some responsible party who is in charge of this
list. Please delete my profile and stop sending messages. This is the
6th such request. 

 

 

 

 

 Sincerely,

 

 Michael Roberts

 Civil Engineering Executive Recruiter

 Corporate Staffing Services

 150 Monument Road, Suite 510

 Bala Cynwyd, PA 19004

 P 610-771-1084

 F 610-771-0390

 E mrobe...@jobscss.com <mailto:mrobe...@jobscss.com> 

 

From: Moses [mailto:jam...@gmail.com] 
Sent: Thursday, May 14, 2009 5:19 AM
To: php-gene...@lists.php.net
Subject: [PHP]Cannot output the same data from text file in PHP

 

Hi Folks,

I have a written a script in PHP which outputs the result from a text
file.
The PHP script is as follows: 

<?php
$alldata = file("result.txt");
echo "<table><tr><td>";
foreach($alldata as $line_num => $line) {
echo $line."<br>";
}
echo"</td></tr></table>";
?>

I have attached the result.txt file. However the output of the script is
as
follows:


Query: 1 atggcaatcgtttcagcagaaaaattcgtaattcgagctcgcccggggatcgatcctcta 60

|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| 
Sbjct: 1 atggcaatcgtttcagcagaaaaattcgtaattcgagctcgcccggggatcgatcctcta 60


which is not exactly  as in the result.txt file in that the pipelines
are displaced.

Any pointer to this problem shall be appreciated. Thanking you in
advance.

Moses


--- End Message ---
--- Begin Message ---
as far as i know you just send an email to:
php-general-unsubscr...@lists.php.net and then reply to the confirmation - its a standard mailing list which you subscribed to at some point, no profiles or such like.

Mike Roberts wrote:
Is there a moderator or some responsible party who is in charge of this
list. Please delete my profile and stop sending messages. This is the
6th such request.
 Sincerely,

 Michael Roberts

 Civil Engineering Executive Recruiter

 Corporate Staffing Services

 150 Monument Road, Suite 510

 Bala Cynwyd, PA 19004

 P 610-771-1084

 F 610-771-0390

E mrobe...@jobscss.com <mailto:mrobe...@jobscss.com> From: Moses [mailto:jam...@gmail.com] Sent: Thursday, May 14, 2009 5:19 AM
To: php-gene...@lists.php.net
Subject: [PHP]Cannot output the same data from text file in PHP

Hi Folks,

I have a written a script in PHP which outputs the result from a text
file.
The PHP script is as follows:
<?php
$alldata = file("result.txt");
echo "<table><tr><td>";
foreach($alldata as $line_num => $line) {
echo $line."<br>";
}
echo"</td></tr></table>";
?>

I have attached the result.txt file. However the output of the script is
as
follows:


Query: 1 atggcaatcgtttcagcagaaaaattcgtaattcgagctcgcccggggatcgatcctcta 60

|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| Sbjct: 1 atggcaatcgtttcagcagaaaaattcgtaattcgagctcgcccggggatcgatcctcta 60


which is not exactly  as in the result.txt file in that the pipelines
are displaced.

Any pointer to this problem shall be appreciated. Thanking you in
advance.

Moses




--- End Message ---
--- Begin Message ---
On Thu, 2009-05-14 at 09:29 -0400, Mike Roberts wrote:
> Is there a moderator or some responsible party who is in charge of this
> list. Please delete my profile and stop sending messages. This is the
> 6th such request. 
> 
As I and many others have said before, the  unsubscribe email address is
on EVERY header sent from the PHP list. Note, I mean headers and not
footers!


Ash
www.ashleysheridan.co.uk


--- End Message ---
--- Begin Message ---
On Thu, May 14, 2009 at 3:29 PM, Ashley Sheridan
<a...@ashleysheridan.co.uk> wrote:
> On Thu, 2009-05-14 at 09:29 -0400, Mike Roberts wrote:
>> Is there a moderator or some responsible party who is in charge of this
>> list. Please delete my profile and stop sending messages. This is the
>> 6th such request.
>>
> As I and many others have said before, the  unsubscribe email address is
> on EVERY header sent from the PHP list. Note, I mean headers and not
> footers!
>
>
> Ash
> www.ashleysheridan.co.uk

Perhaps, but how many people actually (think to) look at e-mail
message headers, other than the basic To, Subject, and Date that are
usually plainly visible in mail clients? And it's not even like mail
clients read the headers and add an Unsubscribe link/button to the UI
when reading a message.  :-)

Andrew

--- End Message ---
--- Begin Message ---
On Thu, 2009-05-14 at 15:30 -0400, Andrew Ballard wrote:
> On Thu, May 14, 2009 at 3:29 PM, Ashley Sheridan
> <a...@ashleysheridan.co.uk> wrote:
> > On Thu, 2009-05-14 at 09:29 -0400, Mike Roberts wrote:
> >> Is there a moderator or some responsible party who is in charge of this
> >> list. Please delete my profile and stop sending messages. This is the
> >> 6th such request.
> >>
> > As I and many others have said before, the  unsubscribe email address is
> > on EVERY header sent from the PHP list. Note, I mean headers and not
> > footers!
> >
> >
> > Ash
> > www.ashleysheridan.co.uk
> 
> Perhaps, but how many people actually (think to) look at e-mail
> message headers, other than the basic To, Subject, and Date that are
> usually plainly visible in mail clients? And it's not even like mail
> clients read the headers and add an Unsubscribe link/button to the UI
> when reading a message.  :-)
> 
> Andrew

No, but that would be a pretty neat idea!


Ash
www.ashleysheridan.co.uk


--- End Message ---
--- Begin Message ---
Ok, I think we are almost there. First I was given "
php-general-unsubscr...@lists.php.net" but that bounced back. Second, I
use MS outlook ( 03 or 07) which does not accurately display headers,
probably ( in my case at all) because it's audience is less savvy than
this audience, and too much information can be dangerous. Thirdly I want
to thank everybody for their attempts, and ask if somebody can copy and
past the address ( provided it is not the same as the one above that did
not work). 





 Sincerely,

 Michael Roberts
 Civil Engineering Executive Recruiter
 Corporate Staffing Services
 150 Monument Road, Suite 510
 Bala Cynwyd, PA 19004
 P 610-771-1084
 F 610-771-0390
 E mrobe...@jobscss.com


-----Original Message-----
From: Ashley Sheridan [mailto:a...@ashleysheridan.co.uk] 
Sent: Thursday, May 14, 2009 3:50 PM
To: Andrew Ballard
Cc: Mike Roberts; Moses; php-gene...@lists.php.net
Subject: Re: [PHP]Cannot output the same data from text file in PHP

On Thu, 2009-05-14 at 15:30 -0400, Andrew Ballard wrote:
> On Thu, May 14, 2009 at 3:29 PM, Ashley Sheridan
> <a...@ashleysheridan.co.uk> wrote:
> > On Thu, 2009-05-14 at 09:29 -0400, Mike Roberts wrote:
> >> Is there a moderator or some responsible party who is in charge of
this
> >> list. Please delete my profile and stop sending messages. This is
the
> >> 6th such request.
> >>
> > As I and many others have said before, the  unsubscribe email
address is
> > on EVERY header sent from the PHP list. Note, I mean headers and not
> > footers!
> >
> >
> > Ash
> > www.ashleysheridan.co.uk
> 
> Perhaps, but how many people actually (think to) look at e-mail
> message headers, other than the basic To, Subject, and Date that are
> usually plainly visible in mail clients? And it's not even like mail
> clients read the headers and add an Unsubscribe link/button to the UI
> when reading a message.  :-)
> 
> Andrew

No, but that would be a pretty neat idea!


Ash
www.ashleysheridan.co.uk


--- End Message ---
--- Begin Message ---
On Thu, 2009-05-14 at 16:01 -0400, Mike Roberts wrote:
> Ok, I think we are almost there. First I was given "
> php-general-unsubscr...@lists.php.net" but that bounced back. Second, I
> use MS outlook ( 03 or 07) which does not accurately display headers,
> probably ( in my case at all) because it's audience is less savvy than
> this audience, and too much information can be dangerous. Thirdly I want
> to thank everybody for their attempts, and ask if somebody can copy and
> past the address ( provided it is not the same as the one above that did
> not work). 
> 
> 
> 
> 
> 
>  Sincerely,
> 
>  Michael Roberts
>  Civil Engineering Executive Recruiter
>  Corporate Staffing Services
>  150 Monument Road, Suite 510
>  Bala Cynwyd, PA 19004
>  P 610-771-1084
>  F 610-771-0390
>  E mrobe...@jobscss.com
> 
> 
> -----Original Message-----
> From: Ashley Sheridan [mailto:a...@ashleysheridan.co.uk] 
> Sent: Thursday, May 14, 2009 3:50 PM
> To: Andrew Ballard
> Cc: Mike Roberts; Moses; php-gene...@lists.php.net
> Subject: Re: [PHP]Cannot output the same data from text file in PHP
> 
> On Thu, 2009-05-14 at 15:30 -0400, Andrew Ballard wrote:
> > On Thu, May 14, 2009 at 3:29 PM, Ashley Sheridan
> > <a...@ashleysheridan.co.uk> wrote:
> > > On Thu, 2009-05-14 at 09:29 -0400, Mike Roberts wrote:
> > >> Is there a moderator or some responsible party who is in charge of
> this
> > >> list. Please delete my profile and stop sending messages. This is
> the
> > >> 6th such request.
> > >>
> > > As I and many others have said before, the  unsubscribe email
> address is
> > > on EVERY header sent from the PHP list. Note, I mean headers and not
> > > footers!
> > >
> > >
> > > Ash
> > > www.ashleysheridan.co.uk
> > 
> > Perhaps, but how many people actually (think to) look at e-mail
> > message headers, other than the basic To, Subject, and Date that are
> > usually plainly visible in mail clients? And it's not even like mail
> > clients read the headers and add an Unsubscribe link/button to the UI
> > when reading a message.  :-)
> > 
> > Andrew
> 
> No, but that would be a pretty neat idea!
> 
> 
> Ash
> www.ashleysheridan.co.uk
> 
> 
Aforementioned headers (at least the important ones!)

Mailing-List: contact php-general-h...@lists.php.net; run by ezmlm
Precedence: bulk
list-help: <mailto:php-general-h...@lists.php.net>
list-unsubscribe: <mailto:php-general-unsubscr...@lists.php.net>
list-post: <mailto:php-gene...@lists.php.net>
List-Id: php-general.lists.php.net

I believe for the unsubscribe the usual practice is  to send an empty
email with the subject line of 'UNSUBSCRIBE'. Empty means no signatures
too ;)


Ash
www.ashleysheridan.co.uk


--- End Message ---
--- Begin Message ---
On Thu, May 14, 2009 at 03:30:44PM -0400, Andrew Ballard wrote:

> On Thu, May 14, 2009 at 3:29 PM, Ashley Sheridan
> <a...@ashleysheridan.co.uk> wrote:
> > On Thu, 2009-05-14 at 09:29 -0400, Mike Roberts wrote:
> >> Is there a moderator or some responsible party who is in charge of this
> >> list. Please delete my profile and stop sending messages. This is the
> >> 6th such request.
> >>
> > As I and many others have said before, the  unsubscribe email address is
> > on EVERY header sent from the PHP list. Note, I mean headers and not
> > footers!
> >
> >
> > Ash
> > www.ashleysheridan.co.uk
> 
> Perhaps, but how many people actually (think to) look at e-mail
> message headers, other than the basic To, Subject, and Date that are
> usually plainly visible in mail clients? And it's not even like mail
> clients read the headers and add an Unsubscribe link/button to the UI
> when reading a message.  :-)

In most email clients, you can turn on full header display.

As a list admin on about six lists and a member of numerous lists, I
find it endlessly aggravating that people can't manage to unsubscribe
their own addresses to email lists. Our LUG has a "lists" page on its
website which clearly step-by-step indicates what must be done to
unsubscribe. Yet people never even look to see if there is such a page.
And then I've had people tell me they followed those instructions
exactly, and it didn't work. No, they didn't or it would have worked,
since people manage to follow those instructions successfully all the
time.

My stance is, if you're going to subscribe to an email list, learn how
to unsubscribe, how to see if you've been inadvertantly unsubscribed,
learn email netiquette on lists, etc.

It reminds me of people who call tech support saying their mouse doesn't
work. Then you find out they've picked it up and pointed it at the
screen to make the pointer move (true story).

If you're going to own a car, learn how to drive it. If you're going to
own a computer, learn how to operate it. If you're going to program,
read a book about it first (yes, you P.J.).

</rant>

Paul

-- 
Paul M. Foster

--- End Message ---
--- Begin Message ---
On Thu, May 14, 2009 at 4:33 PM, Paul M Foster <pa...@quillandmouse.com> wrote:
> On Thu, May 14, 2009 at 03:30:44PM -0400, Andrew Ballard wrote:
>
>> On Thu, May 14, 2009 at 3:29 PM, Ashley Sheridan
>> <a...@ashleysheridan.co.uk> wrote:
>> > On Thu, 2009-05-14 at 09:29 -0400, Mike Roberts wrote:
>> >> Is there a moderator or some responsible party who is in charge of this
>> >> list. Please delete my profile and stop sending messages. This is the
>> >> 6th such request.
>> >>
>> > As I and many others have said before, the  unsubscribe email address is
>> > on EVERY header sent from the PHP list. Note, I mean headers and not
>> > footers!
>> >
>> >
>> > Ash
>> > www.ashleysheridan.co.uk
>>
>> Perhaps, but how many people actually (think to) look at e-mail
>> message headers, other than the basic To, Subject, and Date that are
>> usually plainly visible in mail clients? And it's not even like mail
>> clients read the headers and add an Unsubscribe link/button to the UI
>> when reading a message.  :-)
>
> In most email clients, you can turn on full header display.

Yes, I know you CAN do that. I'm just saying that most people WON'T do
that for two reasons 1) it's an extra step and people are inherently
lazy and 2) it shows a lot more information that most people care to
see. Often the headers are longer than the message.

> As a list admin on about six lists and a member of numerous lists, I
> find it endlessly aggravating that people can't manage to unsubscribe
> their own addresses to email lists. Our LUG has a "lists" page on its
> website which clearly step-by-step indicates what must be done to
> unsubscribe. Yet people never even look to see if there is such a page.
> And then I've had people tell me they followed those instructions
> exactly, and it didn't work. No, they didn't or it would have worked,
> since people manage to follow those instructions successfully all the
> time.
>
> My stance is, if you're going to subscribe to an email list, learn how
> to unsubscribe, how to see if you've been inadvertantly unsubscribed,
> learn email netiquette on lists, etc.
>
> It reminds me of people who call tech support saying their mouse doesn't
> work. Then you find out they've picked it up and pointed it at the
> screen to make the pointer move (true story).
>
> If you're going to own a car, learn how to drive it. If you're going to
> own a computer, learn how to operate it. If you're going to program,
> read a book about it first (yes, you P.J.).
>
> </rant>
>
> Paul
>
> --
> Paul M. Foster

I agree with you for the most part. I'm just saying that the presence
of unsubscribe information in the message headers themselves is of
very little value to most people.

Andrew

--- End Message ---
--- Begin Message ---
On Thu, 2009-05-14 at 16:33 -0400, Paul M Foster wrote:
> On Thu, May 14, 2009 at 03:30:44PM -0400, Andrew Ballard wrote:
> 
> > On Thu, May 14, 2009 at 3:29 PM, Ashley Sheridan
> > <a...@ashleysheridan.co.uk> wrote:
> > > On Thu, 2009-05-14 at 09:29 -0400, Mike Roberts wrote:
> > >> Is there a moderator or some responsible party who is in charge of this
> > >> list. Please delete my profile and stop sending messages. This is the
> > >> 6th such request.
> > >>
> > > As I and many others have said before, the  unsubscribe email address is
> > > on EVERY header sent from the PHP list. Note, I mean headers and not
> > > footers!
> > >
> > >
> > > Ash
> > > www.ashleysheridan.co.uk
> > 
> > Perhaps, but how many people actually (think to) look at e-mail
> > message headers, other than the basic To, Subject, and Date that are
> > usually plainly visible in mail clients? And it's not even like mail
> > clients read the headers and add an Unsubscribe link/button to the UI
> > when reading a message.  :-)
> 
> In most email clients, you can turn on full header display.
> 
> As a list admin on about six lists and a member of numerous lists, I
> find it endlessly aggravating that people can't manage to unsubscribe
> their own addresses to email lists. Our LUG has a "lists" page on its
> website which clearly step-by-step indicates what must be done to
> unsubscribe. Yet people never even look to see if there is such a page.
> And then I've had people tell me they followed those instructions
> exactly, and it didn't work. No, they didn't or it would have worked,
> since people manage to follow those instructions successfully all the
> time.
> 
> My stance is, if you're going to subscribe to an email list, learn how
> to unsubscribe, how to see if you've been inadvertantly unsubscribed,
> learn email netiquette on lists, etc.
> 
> It reminds me of people who call tech support saying their mouse doesn't
> work. Then you find out they've picked it up and pointed it at the
> screen to make the pointer move (true story).
> 
> If you're going to own a car, learn how to drive it. If you're going to
> own a computer, learn how to operate it. If you're going to program,
> read a book about it first (yes, you P.J.).
> 
> </rant>
> 
> Paul
> 
> -- 
> Paul M. Foster
> 
So, erm, driving without learning and getting a license is wrong? :p


Ash
www.ashleysheridan.co.uk


--- End Message ---
--- Begin Message ---
Per Jessen wrote:
kyle.smith wrote:

Most carriers have email-to-sms bridges.  For example, I use AT&T
Wireless and you can text me by sending an email to
myphonenum...@txt.att.net.

Do you end up paying for that then - or who pays for it?
Besides, none of the carriers around here have email-to-sms interfaces,
so I'd disagree with your initial claim.


/Per

It's really only in the US (and possibly Canada) that they have the email-to-sms bridges. Here in the UK (and I think most of Europe) such a thing doesn't exist. Carriers in Europe like to charge a lot of money for SMS. At least we don't have to pay to receive calls like they do in the States!

Ian

--- End Message ---
--- Begin Message ---
I'm sure I've seen something about this before, but I can't find it:

I'm creating a file which needs to live for the duration of a session, and ONLY
the duration of the session.
I made a little call which holds the name of the file like this:
<?php
class __TFR
{
    private $file;
    public function __construct()
    {
        $this->file = '/tmp/'.session_id().'.xml';
    }

    public function __get($name)
    {
        if ($name=='file') return $this->file;
    }

    public function __destruct()
    {
        @unlink($this->file);
    }
}
?>
So I create an instance of this object and I put a reference to the object in
the session:

<?php
    $_SESSION['TFR'] = new __TFR();
?>

I was then expecting TFR::__destruct() to only be called when the session was
closed, with either a timeout, or a session_destroy() call.
But it looks like the object destructor is called at the end of every page.
Any ideas about working around that?


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

--- End Message ---
--- Begin Message ---
2009/5/14 Peter Ford <p...@justcroft.com>:
> I'm sure I've seen something about this before, but I can't find it:
>
> I'm creating a file which needs to live for the duration of a session, and 
> ONLY
> the duration of the session.
> I made a little call which holds the name of the file like this:
> <?php
> class __TFR
> {
>    private $file;
>    public function __construct()
>    {
>        $this->file = '/tmp/'.session_id().'.xml';
>    }
>
>    public function __get($name)
>    {
>        if ($name=='file') return $this->file;
>    }
>
>    public function __destruct()
>    {
>       �...@unlink($this->file);
>    }
> }
> ?>
> So I create an instance of this object and I put a reference to the object in
> the session:
>
> <?php
>    $_SESSION['TFR'] = new __TFR();
> ?>
>
> I was then expecting TFR::__destruct() to only be called when the session was
> closed, with either a timeout, or a session_destroy() call.
> But it looks like the object destructor is called at the end of every page.
> Any ideas about working around that?

The destructor will be called at the end of each page request because
the object in memory is destroyed.

When the object is serialized you will get __sleep being called, and
when it's unserialized you'll get __wakeup.

There is no way to detect when a session is destroyed unless you
implement your own session handler.

-Stuart

-- 
http://stut.net/

--- End Message ---
--- Begin Message ---
Stuart wrote:
> 2009/5/14 Peter Ford <p...@justcroft.com>:
>> I'm sure I've seen something about this before, but I can't find it:
>>
>> I'm creating a file which needs to live for the duration of a session, and 
>> ONLY
>> the duration of the session.
>> I made a little call which holds the name of the file like this:
>> <?php
>> class __TFR
>> {
>>    private $file;
>>    public function __construct()
>>    {
>>        $this->file = '/tmp/'.session_id().'.xml';
>>    }
>>
>>    public function __get($name)
>>    {
>>        if ($name=='file') return $this->file;
>>    }
>>
>>    public function __destruct()
>>    {
>>        @unlink($this->file);
>>    }
>> }
>> ?>
>> So I create an instance of this object and I put a reference to the object in
>> the session:
>>
>> <?php
>>    $_SESSION['TFR'] = new __TFR();
>> ?>
>>
>> I was then expecting TFR::__destruct() to only be called when the session was
>> closed, with either a timeout, or a session_destroy() call.
>> But it looks like the object destructor is called at the end of every page.
>> Any ideas about working around that?
> 
> The destructor will be called at the end of each page request because
> the object in memory is destroyed.
> 
> When the object is serialized you will get __sleep being called, and
> when it's unserialized you'll get __wakeup.
> 
> There is no way to detect when a session is destroyed unless you
> implement your own session handler.
> 
> -Stuart
> 

Oh bother. I guess it's a consequence of the statelessness of the PHP engine.

I thought I might be able to set a flag in __sleep() to indicate that the
session had been serialised rather than destroyed, but __destruct() is called
before __sleep().

I will have to see whether it is worth coding a custom session handler or to
just let the disk fill up... :)

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

--- End Message ---
--- Begin Message ---
Hey all,

I have one flex+PHP application.

Main purpose of the site is to sell T-shirts online.

 

Flex is used for generating different designs on available tshirt.

Something similar to Cafepress dot com.

 

I want to generate 300 DPI tshirt image from flex and send it to PHP side
for processing.

Now the question is Flex doen't support direct image generation.

So flex send's a Bytearray for 300 dpi image which is quite Bigger.some time
it crashes the browser while processing..because of heavy data..

 

And can not store in any of MySQL datatype.

Also storing in a txt file is too much time taking process..

 

Any Suggestion or help to come out fron this issue..

 

 

Regards

Pravin

 


--- End Message ---
--- Begin Message ---
Where and what do I look for to resolve this?
My script is working fine on an active ISP web server.
This morning, I crank up the local XP and the local FreeBSD 7.1 server.
I start my editor, bring up Firefox, go to local server and everything
works fine.
I start to code and make a couple of minor changes, check the output on
the local server - whooosh. Something isn't right. Only the logo shows
from the included header script. I revert the files worked on to the
original and nothing changes - output is not changed.
I check the web server & all is correct. I download the files from the
web and check against the local files. Everything is identical (except
for minor location changes) but the local setup just doesn't output
correctly.
There are no error messages, either in the browser or the var/log files?
What puzzles me is the use of the include files and just how are they
used/implemented? Perhaps there is something there that isn't right?
This is rather weird?
Anyone have any ideas? I'm lost.

-- 
Hervé Kempf: "Pour sauver la planète, sortez du capitalisme."
-------------------------------------------------------------
Phil Jourdan --- p...@ptahhotep.com
   http://www.ptahhotep.com
   http://www.chiccantine.com/andypantry.php


--- End Message ---
--- Begin Message ---
PJ wrote:
> Where and what do I look for to resolve this?
> My script is working fine on an active ISP web server.
> This morning, I crank up the local XP and the local FreeBSD 7.1 server.
> I start my editor, bring up Firefox, go to local server and everything
> works fine.
> I start to code and make a couple of minor changes, check the output on
> the local server - whooosh. Something isn't right. Only the logo shows
> from the included header script. I revert the files worked on to the
> original and nothing changes - output is not changed.
> I check the web server & all is correct. I download the files from the
> web and check against the local files. Everything is identical (except
> for minor location changes) but the local setup just doesn't output
> correctly.
> There are no error messages, either in the browser or the var/log files?
> What puzzles me is the use of the include files and just how are they
> used/implemented? Perhaps there is something there that isn't right?
> This is rather weird?
> Anyone have any ideas? I'm lost.
I have no idea where it came from but there was an entry in the db.php
file that was preventing access to the db. Sorry - false alarm.  :-[


-- 
Hervé Kempf: "Pour sauver la planète, sortez du capitalisme."
-------------------------------------------------------------
Phil Jourdan --- p...@ptahhotep.com
http://www.ptahhotep.com
http://www.chiccantine.com/andypantry.php

--- End Message ---
--- Begin Message ---
How does one deal with tag completion from an include file to the
main(source)-file?
i.e. c should a tag, such as <head> or <div> be closed withing the
include file? Or can <body> be started in the include file and closed in
the main-file?
Crossing the border, so-to-speak, doesn't seem to matter; but how does
this affect validation and execution?
Anyone have a clarification, please?

-- 
Hervé Kempf: "Pour sauver la planète, sortez du capitalisme."
-------------------------------------------------------------
Phil Jourdan --- p...@ptahhotep.com
   http://www.ptahhotep.com
   http://www.chiccantine.com/andypantry.php


--- End Message ---
--- Begin Message ---
PJ wrote:
> How does one deal with tag completion from an include file to the
> main(source)-file?
> i.e. c should a tag, such as <head> or <div> be closed withing the
> include file? Or can <body> be started in the include file and closed in
> the main-file?

It doesn't really matter, however it may be easier to decipher and/or
change later if things are in the same file.

i.e.  many apps use a header.php that includes html, title, head, and
meta tags, maybe body.  They include this on every page, then at the
bottom of every page they include a footer.php that may add a standard
copyright and closes out body html etc.

Many times, repeatable html after the body tag may be included in the
header or in another include file like menu.php or something.

> Crossing the border, so-to-speak, doesn't seem to matter; but how does
> this affect validation and execution?
> Anyone have a clarification, please?
> 

Validation is done on the resultant html output so it's not affected.
Every file include takes time to execute the include, however it's
probably negligible unless you have a very high number of includes.

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

--- End Message ---
--- Begin Message ---
I'm a bit fuzzy on the relationship between the <? ?> and the HTML code.
Where should the php code be placed in a page so that execution is
carried out smoothly? So far, my coding has managed to avoid horrendous
snags; but as I delve deeper into the quagmire of coding, I would like
to clear the fog before me.
Perhaps I have been fortunate up to this point... :-)

-- 
Hervé Kempf: "Pour sauver la planète, sortez du capitalisme."
-------------------------------------------------------------
Phil Jourdan --- p...@ptahhotep.com
   http://www.ptahhotep.com
   http://www.chiccantine.com/andypantry.php


--- End Message ---
--- Begin Message ---
PJ wrote:
> I'm a bit fuzzy on the relationship between the <? ?> and the HTML code.
> Where should the php code be placed in a page so that execution is
> carried out smoothly? So far, my coding has managed to avoid horrendous
> snags; but as I delve deeper into the quagmire of coding, I would like
> to clear the fog before me.
> Perhaps I have been fortunate up to this point... :-)
> 

Well, you place the php code wherever you want it executed.  The file is
parsed line by line top to bottom, so if you have some html for an image
and you want the php to be executed before the image, then you must
place it before the image and vice versa.

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

--- End Message ---
--- Begin Message ---
On 5/14/09 2:52 PM, "Shawn McKenzie" <nos...@mckenzies.net> wrote:

> PJ wrote:
>> I'm a bit fuzzy on the relationship between the <? ?> and the HTML code.
>> Where should the php code be placed in a page so that execution is
>> carried out smoothly? So far, my coding has managed to avoid horrendous
>> snags; but as I delve deeper into the quagmire of coding, I would like
>> to clear the fog before me.
>> Perhaps I have been fortunate up to this point... :-)
>> 
> 
> Well, you place the php code wherever you want it executed.  The file is
> parsed line by line top to bottom, so if you have some html for an image
> and you want the php to be executed before the image, then you must
> place it before the image and vice versa.

that's correct.

another possibility is to use a template system. i like this because you can
have the html code and php code in separate files, which i find easier to
deal with. thus php files always begin with <?php and end with ?> and that's
the only place those tags are seen.

the separation is not 100% clean since there can be fragments of html inside
php strings where the php script generates html to put into the template.

you can find some template libraries in pear. and there are general purpose
php app frameworks that incorporate template (aka layout) schemes.



--- End Message ---
--- Begin Message ---
At 2:35 PM -0400 5/14/09, PJ wrote:
I'm a bit fuzzy on the relationship between the <? ?> and the HTML code.
Where should the php code be placed in a page so that execution is
carried out smoothly? So far, my coding has managed to avoid horrendous
snags; but as I delve deeper into the quagmire of coding, I would like
to clear the fog before me.
Perhaps I have been fortunate up to this point... :-)


PJ:

First, do not use <? ?> -- that's a short tag and it has been depreciated and will not work with xml.

Second, use <?php  ?> instead.

Third, place the php code anywhere you want within the html document (top, bottom, middle, and any where). It makes no difference (other than readability) -- all of it will be executed before the browser see's anything.

Fourth, if you want php to print something along with (inside) the html, simply echo() it, such as:

<h1>
<?php echo("Hello World"); ?>
</h1>

and Hello World will be show as a H1 headline.

Please note, the "()" seen in my use of echo is not necessary -- it's just another one of those things that I do that no one else does. It's not wrong, but it serves no purpose other than it looks good and makes sense *to me* YMMV.

Cheers,

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

--- End Message ---
--- Begin Message ---
On Thu, May 14, 2009 at 04:19:57PM -0400, tedd wrote:


<snip>

>
> Please note, the "()" seen in my use of echo is not necessary -- it's
> just another one of those things that I do that no one else does.

Ohmygosh! I didn't realize Tedd was one of those "using parentheses with
an echo command" guys. I'm sooo disappointed! 

Paul

-- 
Paul M. Foster

--- End Message ---
--- Begin Message ---
Hey all,

I'm inheriting a project that was unsuccessfully off-shored and is now in such bad shape (I've seen the code. It's awful) that they are firing the off-shore company and starting over.

One of the things the other company said was possible, and I'm not familiar with... if I understand correctly, is to create a CD with not just an Excel spreadsheet, but software on that CD that when placed in another computer will open the spreadsheet, allow it to be modified and rewritten back to the CD.

This is part of the requirements.

Does anyone know of such software and its name?

Thanks,
Skip
--
====================================
Skip Evans
Big Sky Penguin, LLC
503 S Baldwin St, #1
Madison WI 53703
608.250.2720
http://bigskypenguin.com
------------------------------------
Those of you who believe in
telekinesis, raise my hand.
 -- Kurt Vonnegut

--- End Message ---
--- Begin Message ---
On Thu, May 14, 2009 at 03:22:12PM -0500, Skip Evans wrote:

> Hey all,
>
> I'm inheriting a project that was unsuccessfully off-shored
> and is now in such bad shape (I've seen the code. It's awful)
> that they are firing the off-shore company and starting over.
>
> One of the things the other company said was possible, and I'm
> not familiar with... if I understand correctly, is to create a
> CD with not just an Excel spreadsheet, but software on that CD
> that when placed in another computer will open the
> spreadsheet, allow it to be modified and rewritten back to the CD.
>
> This is part of the requirements.
>
> Does anyone know of such software and its name?

Maybe offshore, but not here. There are only two possibilities. First
include a copy of Excel on the CD and somehow make it autorun. Yeah,
Microsoft would *love* that. Second, include some other program which
would do the same thing. Good luck with that.

And now the kicker-- write the spreadsheet back to CD. Okay, maybe, if
it's a CD-RW. But who's going to pay attention to that little detail?
And as far as I know, writing to a CD is far more complicated than
writing to a hard drive. You can't overwrite data on a CD-RW. Once
written, it's written. You have to cover up the section that was written
to (in software), and then write the contents again. Eventually, you'll
run out of room. And it almost necessitates having a copy of some
CD-writing software on the CD, since there may not be such software on
the client machine. And all this assumes the user is running Windows.
The binaries for one OS won't run on a different OS.

Now, watch. Someone will get on and say, "Oh sure, you can do that with
such-and-such software. I did it the other day." In which case, just
forget I said anything. ;-}

Paul

-- 
Paul M. Foster

--- End Message ---
--- Begin Message ---
On Thu, 2009-05-14 at 16:50 -0400, Paul M Foster wrote:
> On Thu, May 14, 2009 at 03:22:12PM -0500, Skip Evans wrote:
> 
> > Hey all,
> >
> > I'm inheriting a project that was unsuccessfully off-shored
> > and is now in such bad shape (I've seen the code. It's awful)
> > that they are firing the off-shore company and starting over.
> >
> > One of the things the other company said was possible, and I'm
> > not familiar with... if I understand correctly, is to create a
> > CD with not just an Excel spreadsheet, but software on that CD
> > that when placed in another computer will open the
> > spreadsheet, allow it to be modified and rewritten back to the CD.
> >
> > This is part of the requirements.
> >
> > Does anyone know of such software and its name?
> 
> Maybe offshore, but not here. There are only two possibilities. First
> include a copy of Excel on the CD and somehow make it autorun. Yeah,
> Microsoft would *love* that. Second, include some other program which
> would do the same thing. Good luck with that.
> 
> And now the kicker-- write the spreadsheet back to CD. Okay, maybe, if
> it's a CD-RW. But who's going to pay attention to that little detail?
> And as far as I know, writing to a CD is far more complicated than
> writing to a hard drive. You can't overwrite data on a CD-RW. Once
> written, it's written. You have to cover up the section that was written
> to (in software), and then write the contents again. Eventually, you'll
> run out of room. And it almost necessitates having a copy of some
> CD-writing software on the CD, since there may not be such software on
> the client machine. And all this assumes the user is running Windows.
> The binaries for one OS won't run on a different OS.
> 
> Now, watch. Someone will get on and say, "Oh sure, you can do that with
> such-and-such software. I did it the other day." In which case, just
> forget I said anything. ;-}
> 
> Paul
> 
> -- 
> Paul M. Foster
> 
I've never heard of anything like that, there are so many unknown
variables that I would really feel for the poor team who had to take
that project on! You could do it with a USB drive and a small Linux
distro that was set to run as a boot disk though, and it could do a
whole lot more than just open a spreadsheet up!



Ash
www.ashleysheridan.co.uk


--- End Message ---
--- Begin Message ---
Hi,

I am having trouble connecting to https sites using php's builtin ssl
functions.
I tried:
file_get_contents('https://securesite')
fsockopen('ssl://securesite', 443, $errno, $errstr,20)

and same errors every time:
SSL: connection timeout
Failed to enable crypto

Call to openssl_error_string() returns no error.
Curl worked both within php and as standalone client.
The strange thing is that the connection seemed to be dropped immediately
upon contact with the server, i.e., the call to the above functions failed
immediately, which I think contradicts the "timeout" error.

Any tips on the cause of this issue or how to debug this is appreciated.

Regards,

Jerry.

--- End Message ---
--- Begin Message ---
Jerry Zhao wrote:
> Hi,
> 
> I am having trouble connecting to https sites using php's builtin ssl
> functions.
> I tried:
> file_get_contents('https://securesite')
> fsockopen('ssl://securesite', 443, $errno, $errstr,20)
> 
> and same errors every time:
> SSL: connection timeout
> Failed to enable crypto
> 
> Call to openssl_error_string() returns no error.
> Curl worked both within php and as standalone client.
> The strange thing is that the connection seemed to be dropped immediately
> upon contact with the server, i.e., the call to the above functions failed
> immediately, which I think contradicts the "timeout" error.
> 
> Any tips on the cause of this issue or how to debug this is appreciated.
> 
> Regards,
> 
> Jerry.
> 

Check phpinfo().  What is listed for Registered PHP Streams and
Registered Stream Socket Transports.  Also, is openssl listed under
extensions?

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

--- End Message ---

Reply via email to