php-general Digest 10 Feb 2007 10:57:21 -0000 Issue 4618
Topics (messages 248675 through 248701):
Re: OT - Regular Expression
248675 by: lists.dwsasia.com
248677 by: Jochem Maas
248679 by: Robert Cummings
Http Client in PHP connecting to a Digest authenticated server
248676 by: Manish Marathe
Re: Multi lingual pages
248678 by: Robert Cummings
Re: Text Editor for Windows?
248680 by: Michael Weaver
248687 by: David Giragosian
248689 by: Sancar Saran
248694 by: Jim Lucas
anyone know a good book that ...
248681 by: Jochem Maas
Re: keep SESSION using wget?
248682 by: Robert Cummings
248690 by: Jochem Maas
When are headers sent? (headers_sent function)
248683 by: Philippe Piernot
248684 by: Manish Marathe
248686 by: Robert Cummings
248691 by: Jochem Maas
Updating PHP checkout page
248685 by: Robert
248688 by: Sancar Saran
Re: Is there a way to redefine a constant?
248692 by: Jochem Maas
Re: PHP5 & Commercial Development
248693 by: Jochem Maas
Setting printf results as a variable
248695 by: Stephen
248696 by: Fredrik Thunberg
248697 by: Stephen
Re: base64-encoding in cookies?
248698 by: Fletcher Mattox
248699 by: Robert Cummings
248700 by: Jon Anderson
248701 by: Myron Turner
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 ---
Hi,
I was not having PHP on the machine I am reading this email for the
moment. But I tried to use it together with egrep, but it didn't work.
Maybe egrep is using different syntax for these lookaheads, but with
other tests it has been working same as for preg_match in PHP. As you
see the first simple example works, but fails when I insert the
lookahead.
[EMAIL PROTECTED] ~]$ echo 0123 | egrep '^[0-9]{4}$'
0123
[EMAIL PROTECTED] ~]$ echo 0123 | egrep '^(?=.*2.*)[0-9]{4}$'
[EMAIL PROTECTED] ~]$
/Peter
Quoting Martin Alterisio <[EMAIL PROTECTED]>:
PS: I think you can remove the last .*, leaving the assertion like this:
(?=.*8), and it will still work fine and probably faster (which dosen't
matter under these conditions). But I haven't tried that one (and have
already erased the test file I did to check the regular expression).
2007/2/9, Martin Alterisio <[EMAIL PROTECTED]>:
If you want to do it in one regular expression, without listing each case,
you can use a lookahead assertion:
/^(?=.*8.*)[0-9]{4}$/
The assertion (?=.*8.*) checks that the following matches the expression
contained (.*8.*) which fails if there is not an 8.
2007/2/9, Peter Lauri <[EMAIL PROTECTED]>:
Best group member,
I want to match a four digit number. I allow user to enter with *
syntax. So
8* would match anything that starts with 8 and is 4 digit long so:
/^8[0-9]{3}$/
That was easy. Ok then my other case was: *8, so anything that ends with
8
/^[0-9]{3}8$/
Ok, now the tricky one comes: *8*, so match it incase 8 is anywhere in
the
number. Can be beginning, end or in the middle. The problem that I face
I
cannot find out a good way of doing this correctly. So I ended up with
an
expression like this:
/^(8[0-9]{3}|[0-9]8[0-9]{2}|[0-9]{2}8[0-9]|[0-9]{3}8)$/
This takes care of it and everything, BUT it is so ugly. What I actually
need to construct is: A regular expression that checks if 8 is a part of
the
number, and then that it is four digit long.
The pipe "|" is an OR operator, but are there not any "AND" operator in
Regular Expressions? I have been trying to figure this out for a while
now.
Of course I am using the above syntax right now, but would like to strip
it
down. Maybe not for the performance, but for the beauty of it :-)
If you have any comments and suggestions about this I would be happy.
Best regards,
Peter Lauri
<http://www.dwsasia.com/> www.dwsasia.com - company web site
<http://www.lauri.se/> www.lauri.se - personal web site
< http://www.carbonfree.org.uk/> www.carbonfree.org.uk - become Carbon
Free
--- End Message ---
--- Begin Message ---
[EMAIL PROTECTED] wrote:
> Hi,
>
> I was not having PHP on the machine I am reading this email for the
> moment. But I tried to use it together with egrep, but it didn't work.
> Maybe egrep is using different syntax for these lookaheads, but with
> other tests it has been working same as for preg_match in PHP. As you
> see the first simple example works, but fails when I insert the lookahead.
>
> [EMAIL PROTECTED] ~]$ echo 0123 | egrep '^[0-9]{4}$'
> 0123
> [EMAIL PROTECTED] ~]$ echo 0123 | egrep '^(?=.*2.*)[0-9]{4}$'
> [EMAIL PROTECTED] ~]$
>
I couldn't get egrep to work either but the following cmdline output
shows that the given regexp will do the job with preg_match:
tina:~# php -r ' echo preg_match("#^(?=\\d*8\\d*)[0-9]{4}\$#", "8123"),"\n"; '
1
tina:~# php -r ' echo preg_match("#^(?=\\d*8\\d*)[0-9]{4}\$#", "08123"),"\n"; '
0
tina:~# php -r ' echo preg_match("#^(?=\\d*8\\d*)[0-9]{4}\$#", "0812"),"\n"; '
1
tina:~# php -r ' echo preg_match("#^(?=\\d*8\\d*)[0-9]{4}\$#", "20812"),"\n"; '
0
tina:~# php -r ' echo preg_match("#^(?=\\d*8\\d*)[0-9]{4}\$#", "2081"),"\n"; '
1
tina:~# php -r ' echo preg_match("#^(?=\\d*8\\d*)[0-9]{4}\$#", "2008"),"\n"; '
1
> /Peter
>
>
>
> Quoting Martin Alterisio <[EMAIL PROTECTED]>:
>
>> PS: I think you can remove the last .*, leaving the assertion like this:
>> (?=.*8), and it will still work fine and probably faster (which dosen't
>> matter under these conditions). But I haven't tried that one (and have
>> already erased the test file I did to check the regular expression).
>>
>> 2007/2/9, Martin Alterisio <[EMAIL PROTECTED]>:
>>>
>>> If you want to do it in one regular expression, without listing each
>>> case,
>>> you can use a lookahead assertion:
>>>
>>> /^(?=.*8.*)[0-9]{4}$/
>>>
>>> The assertion (?=.*8.*) checks that the following matches the expression
>>> contained (.*8.*) which fails if there is not an 8.
>>>
>>> 2007/2/9, Peter Lauri <[EMAIL PROTECTED]>:
>>>>
>>>> Best group member,
>>>>
>>>>
>>>>
>>>> I want to match a four digit number. I allow user to enter with *
>>>> syntax. So
>>>> 8* would match anything that starts with 8 and is 4 digit long so:
>>>>
>>>>
>>>>
>>>> /^8[0-9]{3}$/
>>>>
>>>>
>>>>
>>>> That was easy. Ok then my other case was: *8, so anything that ends
>>>> with
>>>> 8
>>>>
>>>>
>>>>
>>>> /^[0-9]{3}8$/
>>>>
>>>>
>>>>
>>>> Ok, now the tricky one comes: *8*, so match it incase 8 is anywhere in
>>>> the
>>>> number. Can be beginning, end or in the middle. The problem that I face
>>>> I
>>>> cannot find out a good way of doing this correctly. So I ended up with
>>>> an
>>>> expression like this:
>>>>
>>>>
>>>>
>>>> /^(8[0-9]{3}|[0-9]8[0-9]{2}|[0-9]{2}8[0-9]|[0-9]{3}8)$/
>>>>
>>>>
>>>>
>>>> This takes care of it and everything, BUT it is so ugly. What I
>>>> actually
>>>>
>>>> need to construct is: A regular expression that checks if 8 is a
>>>> part of
>>>> the
>>>> number, and then that it is four digit long.
>>>>
>>>>
>>>>
>>>> The pipe "|" is an OR operator, but are there not any "AND" operator in
>>>> Regular Expressions? I have been trying to figure this out for a while
>>>> now.
>>>> Of course I am using the above syntax right now, but would like to
>>>> strip
>>>> it
>>>> down. Maybe not for the performance, but for the beauty of it :-)
>>>>
>>>>
>>>>
>>>> If you have any comments and suggestions about this I would be happy.
>>>>
>>>>
>>>>
>>>> Best regards,
>>>>
>>>> Peter Lauri
>>>>
>>>>
>>>>
>>>> <http://www.dwsasia.com/> www.dwsasia.com - company web site
>>>>
>>>> <http://www.lauri.se/> www.lauri.se - personal web site
>>>>
>>>> < http://www.carbonfree.org.uk/> www.carbonfree.org.uk - become Carbon
>>>> Free
>>>>
>>>>
>>>>
>>>>
>>>
>
> --PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
--- End Message ---
--- Begin Message ---
On Fri, 2007-02-09 at 15:16 +0000, Edward Kay wrote:
> > > As Rob suggested, why not just use two checks? e.g.
> > >
> > > if ( (strlen($input) == 4) && (strpos($input, '8') !== FALSE ) ) {
> > > // OK
> > > } else {
> > > // Not OK
> > > }
> > >
> > > Not only is this logic much easier to understand than a regexp
> > - important
> > > when someone else has to maintain your code later on etc., I
> > also believe it
> > > will be faster than using preg_match.
> >
> > Those would be the wrong two checks, you'd need 3 checks to do it that
> > way, I still suggested using a regex. The reason being that the original
> > requirements need the entire input to be digits :)
> >
> > <?php
> >
> > if( ereg( '^[[:digit:]]{4}$', $input )
> > &&
> > strpos( $input, '8' ) )
> > {
> > // woot!
> > }
> >
> > // Or alternatively...
> >
> > if( strlen( $input ) == 4
> > &&
> > strpos( $input, '8' )
> > &&
> > ctype_digit( $input ) )
> > {
> > // woot!
> > }
> >
> > ?>
> >
> > Cheers,
> > Rob.
>
> Oops - good catch!
>
> You still need the !== FALSE
Doh! I should have caught that :)
Cheers,
Rob.
--
.------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com |
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting |
| a powerful, scalable system for accessing system services |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for |
| creating re-usable components quickly and easily. |
`------------------------------------------------------------'
--- End Message ---
--- Begin Message ---
Hello,
I have seen some implementations of Server in php implementing HTTP Digest
Authentication but I have not seen any guidelines on HTTP Client connecting
to a specific host, and using the "realm", the username and password to get
authenticated and thereby do something like download files etc.
Any help on there?
Thanks
--
=-MM
--- End Message ---
--- Begin Message ---
On Fri, 2007-02-09 at 19:21 +0100, Frank Arensmeier wrote:
> 9 feb 2007 kl. 15.38 skrev Tim:
>
> >
> >
> >> -----Message d'origine-----
> >> De : Frank Arensmeier [mailto:[EMAIL PROTECTED]
> >> Envoyé : vendredi 9 février 2007 14:51
> >> À : Robert Cummings
> >> Cc : PHP List; Jochem Maas; Otto Wyss
> >> Objet : Re: [PHP] Multi lingual pages
> >>
> >> Thank you Robert.
> >>
> >> Actually, I am not so sure anymore if my idea of "binding"
> >> localized content to domains is the right path to go. After a
> >> litte research, I saw that many of the major sites out there
> >> are redirecting the user to subfolders.
> > As a question or maybe a comment i'm not sure which yet, but aren't
> > those
> > "major" sites rewriting url's rather then redirecting the pages to
> > different
> > folders?
>
> Yes, of course. Maintaining such a site without rewriting urls would
> be a nightmare. When I said that those sites are "redirecting" users,
> I was thinking about response headers.
Why do you need to rewrite URLs?
Cheers,
Rob.
--
.------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com |
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting |
| a powerful, scalable system for accessing system services |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for |
| creating re-usable components quickly and easily. |
`------------------------------------------------------------'
--- End Message ---
--- Begin Message ---
Hi,
I am a Mac person first and foremost, but the Windows people that I
know tend to use Homesite:
http://www.adobe.com/products/homesite/
From what I can tell, even though it is bundled with Dreamweaver 8,
it still looks like it can be purchased and demoed separately.
On Feb 9, 2007, at 1:20 AM, [EMAIL PROTECTED] wrote:
Re: Text Editor for Windows?
Best regards,
Mike Weaver
--
Michael Weaver
Founder/Chief Facilitator
Dynamic Insight
Enhancing Professional Awareness & Communication
Tel: 1.814.574.4871
Email: [EMAIL PROTECTED]
The information in this email and subsequent attachments may contain
confidential information that is intended solely for the attention
and use of
the named addressee(s). This message or any part thereof must not be
disclosed,
copied, distributed or retained by any person without authorization
from the
addressee. If you are not the intended recipient, please contact the
sender by
reply email and destroy all copies of the original message.
--- End Message ---
--- Begin Message ---
I've been using SciTE for many years now.
http://www.scintilla.org/SciTE.html
It's small and lightweight, has code folding and bracket highlighting and a
lot of other nifty features.
I also have Zend Studio IDE Professional but it is slow and bloated compared
with SciTE.
2 more pennies...
David
--- End Message ---
--- Begin Message ---
I bet for one more week about this topic ? Any bidders ?
:)
Regards
Sancar
--- End Message ---
--- Begin Message ---
Sancar Saran wrote:
I bet for one more week about this topic ? Any bidders ?
:)
Regards
Sancar
I bet that a week after that, the question will be asked again... :)
--
Enjoy,
Jim Lucas
Different eyes see different things. Different hearts beat on different
strings. But there are times for you and me when all such things agree.
- Rush
--- End Message ---
--- Begin Message ---
gives in depth, detailed advice on how to design/setup redundant,
load-balanced, high-performance web-server systems/applications with particular
focus on PHP.
I just bought 'Building Scalable Websites' by Cal Henderson and that's looking
like it's a good place for me to start, maybe someone has another
recommendation?
rgds,
Jochem
--- End Message ---
--- Begin Message ---
On Fri, 2007-02-09 at 16:50 +0100, RalfGesellensetter wrote:
> Am Donnerstag 08 Februar 2007 20:36 schrieb Robert Cummings:
> > Or...
> >
> > wget --save-cookies cookies.txt --load-cookies cookies.txt
> > --keep-session-cookies http://my.domain/tracker.php
> >
> > You only need one cumulative call.
>
>
> Dear Rob, thanks again. However, my server uses Debian Sarge with wget
> 1.9.1-12. In this version, the option --keep-session-cookies is not
> implemented :(
Can't you just build an updated wget?
> I also realised that the wget calls push up the PID ids > 32,000. Is
> this going to be a problem? Or can I use a kill - SIGUSR1 to revive
> some background process any few minutes?
No idea, not sure what you're talking about :/
Cheers,
Rob.
--
.------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com |
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting |
| a powerful, scalable system for accessing system services |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for |
| creating re-usable components quickly and easily. |
`------------------------------------------------------------'
--- End Message ---
--- Begin Message ---
RalfGesellensetter wrote:
> Am Donnerstag 08 Februar 2007 20:36 schrieb Robert Cummings:
>> Or...
>>
>> wget --save-cookies cookies.txt --load-cookies cookies.txt
>> --keep-session-cookies http://my.domain/tracker.php
>>
>> You only need one cumulative call.
>
>
> Dear Rob, thanks again. However, my server uses Debian Sarge with wget
> 1.9.1-12. In this version, the option --keep-session-cookies is not
> implemented :(
>
> I also realised that the wget calls push up the PID ids > 32,000. Is
> this going to be a problem? Or can I use a kill - SIGUSR1 to revive
> some background process any few minutes?
>
> I feel that this is going off-topic, so thanks for your understanding ;)
>
> To get back to PHP issues: No, constants are not what I was looking for,
> as I need to change the IP with the next call. But a variable that
> keeps its value and is global for all sessions.
places to store data:
shared memory?
a file?
a db?
just thinking out loud.
>
> Regards
> Ralf
>
--- End Message ---
--- Begin Message ---
I understand that the headers_sent() function will tell me whether headers
have been sent or not.
What I do not understand is what triggers the headers to be sent to the
browser in the first place.
Does this happen as soon as the first output occurs?
--- End Message ---
--- Begin Message ---
On 2/9/07, Philippe Piernot <[EMAIL PROTECTED]> wrote:
I understand that the headers_sent() function will tell me whether headers
have been sent or not.
What I do not understand is what triggers the headers to be sent to the
browser in the first place.
Does this happen as soon as the first output occurs?
It happens just "before" the first output occurs to the browser.
--
Manish Marathe
SpikeSource, Inc.
http://developer.spikesource.com
--- End Message ---
--- Begin Message ---
On Fri, 2007-02-09 at 11:24 -0800, Philippe Piernot wrote:
> I understand that the headers_sent() function will tell me whether headers
> have been sent or not.
> What I do not understand is what triggers the headers to be sent to the
> browser in the first place.
> Does this happen as soon as the first output occurs?
Probably. Unless you have output buffering enabled, in which case
headers are sent when the PHP process completes.
Cheers,
Rob.
--
.------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com |
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting |
| a powerful, scalable system for accessing system services |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for |
| creating re-usable components quickly and easily. |
`------------------------------------------------------------'
--- End Message ---
--- Begin Message ---
Robert Cummings wrote:
> On Fri, 2007-02-09 at 11:24 -0800, Philippe Piernot wrote:
>> I understand that the headers_sent() function will tell me whether headers
>> have been sent or not.
>> What I do not understand is what triggers the headers to be sent to the
>> browser in the first place.
>> Does this happen as soon as the first output occurs?
>
> Probably. Unless you have output buffering enabled, in which case
> headers are sent when the PHP process completes.
or whenever the outer most output buffer is flushed [to the client]
- whichever comes first.
>
> Cheers,
> Rob.
--- End Message ---
--- Begin Message ---
Hopefully I will manage to explain my problem and you will have a solution
for it :).
I have a checkout page, coded in PHP (by some other coder, not available
anymore). On the page I have one table containing shopping cart items and
one submission form, to collect all information from the customer. When the
page is loaded, the table is filled with data from the temporary data table
through SQL query (collected on the previous page, shopping cart page),
except for the field about the amount of the sales tax, which is not yet
known because I don't know anything about the customer. So I have a shopping
cart table and a blank form below that, ready to be filled with customer's
information.
Now, my question is: How can I calculate and fill the sales tax field in the
shopping cart table, if the customer chooses his state from the drop down
list in the form? I must say here that the sales tax is only applicable for
residents of just one state, Vermont, because the company is based in
Vermont. For instance, if the customer chooses Vermont as his state, how
this can be translated into sales tax amount, added into the field in the
shopping cart table and recalculated the total amount? Should the page be
reloaded, with changed value of some variable for the sales tax? Should the
JavaScript be used?
All information entered in the form should be kept after the selection of
the state and calculation is made (I assume that the page should be
reloaded/refreshed), so the user shouldn't have to re-enter them again.
After this recalculation, the customer hits the "Make Purchase" button and
the form is submitted and the receipt for the purchase is sent.
I'm not very familiar with PHP or JavaScript, so any help is greatly
appreciated.
Thanks,
Robert
--- End Message ---
--- Begin Message ---
On Friday 09 February 2007 21:29, Robert wrote:
Greetings,
This is about to your aproach to problem.
For my point of view there are too many solution.
1-) Is that customer may have to register himself? If so you may get from his
state date from here (when customer register himself you require his state
data). This solution can be done in PHP.
2-) If that justomer may not have to register. This is mainly Javascript
solution. A liddle js library may solve this. Of course you can post his data
to server and calculate tax then post back again.
3-) And or you may generate ajax solution for this. When user selects his
state, script auto post and get calculated tax.
4-) and of course BEST WAY is find a professional php programmer. Then tell
what do you want.
Ps: Also you may guessing STATE via IP number checking. (and this was not 100%
safe way)
Regards
Sancar
> Hopefully I will manage to explain my problem and you will have a solution
> for it :).
> I have a checkout page, coded in PHP (by some other coder, not available
> anymore). On the page I have one table containing shopping cart items and
> one submission form, to collect all information from the customer. When the
> page is loaded, the table is filled with data from the temporary data table
> through SQL query (collected on the previous page, shopping cart page),
> except for the field about the amount of the sales tax, which is not yet
> known because I don't know anything about the customer. So I have a
> shopping cart table and a blank form below that, ready to be filled with
> customer's information.
>
> Now, my question is: How can I calculate and fill the sales tax field in
> the shopping cart table, if the customer chooses his state from the drop
> down list in the form? I must say here that the sales tax is only
> applicable for residents of just one state, Vermont, because the company is
> based in Vermont. For instance, if the customer chooses Vermont as his
> state, how this can be translated into sales tax amount, added into the
> field in the shopping cart table and recalculated the total amount? Should
> the page be reloaded, with changed value of some variable for the sales
> tax? Should the JavaScript be used?
> All information entered in the form should be kept after the selection of
> the state and calculation is made (I assume that the page should be
> reloaded/refreshed), so the user shouldn't have to re-enter them again.
> After this recalculation, the customer hits the "Make Purchase" button and
> the form is submitted and the receipt for the purchase is sent.
>
>
>
> I'm not very familiar with PHP or JavaScript, so any help is greatly
> appreciated.
>
>
>
>
> Thanks,
> Robert
--- End Message ---
--- Begin Message ---
please keep the replies 'on list' ...
Khai Doan wrote:
> Sorry, I hit the Send button by mistake. My problem is that these
> constant are defined at compile / startup time, before my script get to
> run. In Perl, I can close STDERR and STDOUT and re-open them to any
> file at anytime. In Perl, I can also use the BEGIN block.
> Is there a BEGIN block in PHP?
no - there is the auto_prepend_file ini setting - but that won't help you.
>
> Can I prevent STDERR and STDOUT from being defined at startup time?
no that I now of (unless you hack the source.)
> I am using CLI.
we figured as much.
can you not redirect stderr/stdout from the cmdline that starts your script?
otherwise you would be stuck with not using those constants and defining
variables
that point to the stream(s) you want to output to ... AFAIT this should be
neither
a problem nor a hack.
>
> Thanks
> Khai
> Jochem Maas wrote:
>
>> Khai wrote:
>>
>>
>>> STDERR and STDOUT are defined as constants. Is there a way to redefine
>>> these constants?
>>>
>>
>> only if you use runkit (which is probably not recommended in
>> production environments):
>>
>> http://php.net/runkit
>>
>> consider that constants are called as such for a reason. you should
>> consider that
>> it's probably better to define & use a couple of userland vars to
>> point to whatever
>> it is you want to point to - either that or redirect stdout/stderr in
>> the shell/cmdline that calls
>> your script instead.
>>
>>
>>
>>> Thanks
>>> Khai
>>>
>>>
>>
>>
>>
>
--- End Message ---
--- Begin Message ---
Ligaya A. Turmelle wrote:
> Law of mass tonnage - better to be in the big motorized vehicle then the
> little one when *crunch* happens.
and especially not under it as Richard pointed out. :-/
>
> Respectfully,
> Ligaya Turmelle
> Systems Analyst
> Guamcell Communications
> Phone: (671)689-2377
> -----Original Message-----
> From: Stut [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, February 06, 2007 2:55 AM
> To: tedd
> Cc: [email protected]
> Subject: Re: [PHP] PHP5 & Commercial Development
>
> tedd wrote:
>> At 12:06 AM -0500 2/5/07, Craige Leeder wrote:
>>> PHP is fine for commercial environments. Many people are just afraid
>>> of it due to the fact it is known to break some poorly written PHP 4
>>> scripts, and the fact that many people don't think it's new features
>>> are "necessary". It is perfectly fine to use it in a commercial
>>> environment however.
>> I feel the same way about cars. There are some terrible drivers out
>> there, so we should all take the bus.
>
> Won't work. There are some *really* terrible bus drivers out there.
>
> -Stut
>
> --
> PHP General Mailing List (http://www.php.net/) To unsubscribe, visit:
> http://www.php.net/unsub.php
>
--- End Message ---
--- Begin Message ---
Hi list, I'm trying to make a script which requires that I perform a
printf() formatting on a string, but instead of outputting the result I
need to set the result as a variable to write to a file. Can any one
advise me on how to do this? or if it's even possible?
Kind regards, Stephen.
--- End Message ---
--- Begin Message ---
Stephen wrote:
Hi list, I'm trying to make a script which requires that I perform a
printf() formatting on a string, but instead of outputting the result
I need to set the result as a variable to write to a file. Can any one
advise me on how to do this? or if it's even possible?
Kind regards, Stephen.
sprintf...
--- End Message ---
--- Begin Message ---
Thanks for the quick response... I feel stupid now though! I can't
believe I missed that.
Kind regards, Stephen.
Fredrik Thunberg wrote:
Stephen wrote:
Hi list, I'm trying to make a script which requires that I perform a
printf() formatting on a string, but instead of outputting the result
I need to set the result as a variable to write to a file. Can any
one advise me on how to do this? or if it's even possible?
Kind regards, Stephen.
sprintf...
--- End Message ---
--- Begin Message ---
Robert Cummings writes:
> Dear numnutz, get off your lazy arse and read the doc for yourself:
>
> http://wp.netscape.com/newsref/std/cookie_spec.html
>
> It clearly states:
>
> NAME=VALUE
> This string is a sequence of characters excluding semi-colon, comma and
> white space. If there is a need to place such data in the name or value,
> some encoding method such as URL style %XX encoding is recommended,
> though no encoding is defined or required.
>
> There, it left the encoding up to whoever is decoding it. Now feel free
> to take your troll ass and hide under a bridge someplace.
Actually, wouldn't you say it is left up to whoever is sending the cookie?
But more on that later.
Here is my point of view, if you are interested. When the specification
for a language reads "encoding is recommended, but not required", then
it is leaving the decision to encode or not to encode up to the sender.
The sender is in the driver's seat and the receiver must follow suite.
(Side note: this is an inherently BAD specification since it requires
out-of-band agreement between the sender and receiver, and this is what
puts the developers of PHP in such a tough position.) The receiver must
be able to handle either case. But PHP does not permit this. Instead,
PHP, in an attempt to avoid the chaos inherent a bad spec, has made the
decision for the sender. The sender must encode, and has no choice.
I think this is at the root of my frustration. I want control. :)
Also, keep in mind that in my case the sender is a third party over
whom I have no control. Given a spec like this, I prefer cooperation
between sender and receiver rather than a decision by fiat made by the
programming language.
Now that I have seen the spec (thank you!), I can at least understand
why the PHP developers made the decision they did. I still disagree
with it, but I was seeking only an understanding, and I have found that.
I hope you will agree I was not trolling here.
Oh. One more thought. If you wish to argue that PHP does provide
for both cases with $_COOKIE and $_SERVER['HTTP_COOKIE'], then I will
grudgingly agree with you. See we can agree. :) In that case, all I ask
is for a little documentation. Is the distinction in these two variables
documented somewhere? I have looked and looked and have come up empty.
I am asking this question with humility and sincerity. I am asking it
because I honestly wish to learn. I think you have misjudged my motives
and my character.
Thank you,
Fletcher
--- End Message ---
--- Begin Message ---
On Fri, 2007-02-09 at 20:38 -0600, Fletcher Mattox wrote:
> Robert Cummings writes:
>
> > Dear numnutz, get off your lazy arse and read the doc for yourself:
> >
> > http://wp.netscape.com/newsref/std/cookie_spec.html
> >
> > It clearly states:
> >
> > NAME=VALUE
> > This string is a sequence of characters excluding semi-colon, comma and
> > white space. If there is a need to place such data in the name or value,
> > some encoding method such as URL style %XX encoding is recommended,
> > though no encoding is defined or required.
> >
> > There, it left the encoding up to whoever is decoding it. Now feel free
> > to take your troll ass and hide under a bridge someplace.
>
> Actually, wouldn't you say it is left up to whoever is sending the cookie?
> But more on that later.
>
> Here is my point of view, if you are interested. When the specification
> for a language reads "encoding is recommended, but not required", then
> it is leaving the decision to encode or not to encode up to the sender.
> The sender is in the driver's seat and the receiver must follow suite.
But isn't the sender and receiver usually one and the same. I mean your
PHP application is usually what set the cookie in the first place. Then
you receive it in the very same PHP application. I realize that the
cookie is technically sent by the browser, but the browser doesn't
process cookies other than to store them. It's akin to sending a message
into the future to yourself in some encoded format. You are both the
sender and receiver and so one would expect you can decipher your own
message.
> (Side note: this is an inherently BAD specification since it requires
> out-of-band agreement between the sender and receiver, and this is what
> puts the developers of PHP in such a tough position.) The receiver must
> be able to handle either case. But PHP does not permit this. Instead,
> PHP, in an attempt to avoid the chaos inherent a bad spec, has made the
> decision for the sender.
Well PHP made the decision with the greatest flexibility. It chose to
encode the cookie in such a way as to allow developers to include
special characters in the cookie value.
> The sender must encode, and has no choice.
> I think this is at the root of my frustration. I want control. :)
You have control over the value you insert into the cookie. If you find
the encoding problematic, you have the control to encode it first in
base64 (as this message happens to be titled). So where exactly do you
see loss of control?
> Also, keep in mind that in my case the sender is a third party over
> whom I have no control. Given a spec like this, I prefer cooperation
> between sender and receiver rather than a decision by fiat made by the
> programming language.
Ah, so you have a mixed language environment. Well you can use the
header() function to send the cookie header yourself. This allows you
control over the sending. You can also use apache_request_headers() to
get full control over the incoming request headers.
>
> Now that I have seen the spec (thank you!), I can at least understand
> why the PHP developers made the decision they did. I still disagree
> with it, but I was seeking only an understanding, and I have found that.
> I hope you will agree I was not trolling here.
Yep.
> Oh. One more thought. If you wish to argue that PHP does provide
> for both cases with $_COOKIE and $_SERVER['HTTP_COOKIE'], then I will
I'm not aware of a $_SERVER['HTTP_COOKIE'] field. Perhaps you meant
$GLOBALS['HTTP_COOKIE_VARS']? If so, it is identical to $_COOKIE with
$GLOBALS['HTTP_COOKIE_VARS'] being deprecated.
> grudgingly agree with you. See we can agree. :) In that case, all I ask
> is for a little documentation. Is the distinction in these two variables
> documented somewhere? I have looked and looked and have come up empty.
> I am asking this question with humility and sincerity. I am asking it
> because I honestly wish to learn. I think you have misjudged my motives
> and my character.
http://www.php.net/manual/en/function.header.php
http://www.php.net/manual/en/function.apache-response-headers.php
Hope that helps.
Cheers,
Rob.
--
.------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com |
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting |
| a powerful, scalable system for accessing system services |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for |
| creating re-usable components quickly and easily. |
`------------------------------------------------------------'
--- End Message ---
--- Begin Message ---
Fletcher Mattox wrote:
Actually, wouldn't you say it is left up to whoever is sending the cookie?
But more on that later.
It is totally left up to the user with PHP as well, but you agree with
that (grudgingly) later. There is no way that you can argue the fact
that there are two mechanisms. One leaves total control up to the user,
the other is totally automatic. Personally, I think that's having your
cake, and eating it too.
I won't argue that this behavior should probably be documented with
$_COOKIE, but it is documented with it's counterpart, setcookie: "Note
that the value portion of the cookie will automatically be urlencoded
when you send the cookie, and when it is received, it is automatically
decoded and assigned to a variable by the same name as the cookie name.
If you don't want this, you can use setrawcookie()
<http://www.php.net/manual/en/function.setrawcookie.php> instead if you
are using PHP 5."
In terms of the behavior, I think it makes total sense. The only case
where it would ever bite you is yours (which is rare because most people
wouldn't mix perl and PHP in the same system). Nearly every other case
is neatly wrapped up - newbies will find that setting whatever cookies
they want just works, regardless of content. Others who are aware of the
encoding behavior probably don't care - it's what they'd do manually if
PHP didn't do it for them. Even if you use cookies in JavaScript, you'll
have to know that certain charaters would have to be escaped, so you'd
run escape on your cookie and find that in PHP you don't even have to do
anything and it just works. (And more or less vice-versa.)
As far as I'm concerned, that is the mentality of PHP: there's a
function called: do_exactly_what_i_want(), and it just works.
I think some of the negativity aimed at you stems from the fact that the
behavior has been explained and is quite clear. There isn't much point
in arguing what it should be. It is exactly what it is. If you want to
argue what the behavior should be, try php-dev. (Making that kind of
argument here is like yelling at your neighbor 'cause Vista
sucks...assuming Bill Gates isn't your neighbor. :-)
jon
--- End Message ---
--- Begin Message ---
Jon Anderson wrote:
Fletcher Mattox wrote:
In terms of the behavior, I think it makes total sense. The only case
where it would ever bite you is yours (which is rare because most
people wouldn't mix perl and PHP in the same system).
I'm not going to get into the middle of the base64 argument, but I don't
think that mixing perl and php is rare. I've seen the mix occasionally
crop up up this list, and I know from myself. I've been using Perl for
10 years and PHP for only 2.5. It's inevitable that I'll choose Perl
for certain uses and that I'll call the Perl as cgi from pages scripted
in PHP. Then there are things which I've already got written in Perl
that I also call as cgi from PHP pages. Or operations that are not
compiled into all installs of PHP and are standard with Perl, like
fork(), and there's nothing you can do about it because you don't have
control over the installation. Each language has its strengths. What's
true of Perl, I think is probably true of Python as well. There are
lots of programmers and web sties that must mix Python and PHP.
--
_____________________
Myron Turner
http://www.room535.org
http://www.bstatzero.org
http://www.mturner.org/XML_PullParser/
--- End Message ---