php-general Digest 16 Nov 2006 09:19:33 -0000 Issue 4462
Topics (messages 244694 through 244708):
cURL uses
244694 by: Philip Thompson
244695 by: Dave Goodchild
244696 by: Jon Anderson
244697 by: Eric Butera
244698 by: cajbecu
244708 by: clive
Re: Splitting a string
244699 by: Børge Holen
244701 by: Chris
244702 by: Robert Cummings
244703 by: Chris
244704 by: Paul Novitski
Re: Highjack?
244700 by: Chris
Smart Quotes not so smart
244705 by: Larry Garfield
244706 by: Robert Cummings
244707 by: Travis Doherty
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've been doing some reading trying to figure out why I would want to
use cURL. I have not found a solid reason yet. Does anyone have a
useful example on why you would want to use cURL?
Thanks,
~Philip
--- End Message ---
--- Begin Message ---
You would use cURL to achieve the things cURL is built to achieve?
--- End Message ---
--- Begin Message ---
Philip Thompson wrote:
I've been doing some reading trying to figure out why I would want to
use cURL. I have not found a solid reason yet. Does anyone have a
useful example on why you would want to use cURL?
It allows significant configurability and flexibility over PHP's more
direct functions, for example, the ability to set a timeout, or get more
direct control over output. You only have to read the curl documentation
to see that it can do a lot of things that other PHP functions just
can't do.
I would suggest that you probably shouldn't try to find a reason to use
curl, rather a reason to use curl will find you.
jon
--- End Message ---
--- Begin Message ---
On 11/15/06, Philip Thompson <[EMAIL PROTECTED]> wrote:
Hi.
I've been doing some reading trying to figure out why I would want to
use cURL. I have not found a solid reason yet. Does anyone have a
useful example on why you would want to use cURL?
Thanks,
~Philip
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Interfacing with payment/shipping gateway APIs. For example, in my
store I must send post data to a payment gateway to tell them the
amount, cc#, etc. and they will return text telling me the transaction
passed/failed/etc.
--- End Message ---
--- Begin Message ---
well, there are more reasons you should use cURL ..
- control and flexibility of the output,
- post variables,
- can interact with secure servers (ssl - supports certificates)
- can use with proxys (http/socks)
- set timeouts
- easily modify headers :)
- use different ip`s of the server when it`s used (if it is configured to do so)
please read documentation at php.net/curl before changing your mind to
not use it. it helps you a lot in your applications. an old frend told
me.. you`ll love this class - what to see.. it happend :)
On 11/15/06, Philip Thompson <[EMAIL PROTECTED]> wrote:
Hi.
I've been doing some reading trying to figure out why I would want to
use cURL. I have not found a solid reason yet. Does anyone have a
useful example on why you would want to use cURL?
Thanks,
~Philip
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---
Dave Goodchild wrote:
You would use cURL to achieve the things cURL is built to achieve?
Wow that answer is not even worth the calories your burned type it.
"Theres not such thing as stupid questions, only stupid answers"
In your case this phrase holds some truth.
--- End Message ---
--- Begin Message ---
Oh this was good.
I added a while loop to insert extra strings "0" in front of the number to add
if the string is less than 5 chars short.
I forgot to mentinon that the string actually could be shorter (just found
out) and the code didn't work with fewer than 5 char strings.
But now is rocks.
Thanks again.
On Wednesday 15 November 2006 06:24, Paul Novitski wrote:
> At 11/14/2006 03:17 PM, Børge Holen wrote:
> >$number = 123456789
> >
> >should print as following:
> >var1: 12345 (and it is this lengt witch varies)
> >var2: 67
> >var3: 89.
>
> You can also do this with a regular expression:
>
> $iNumber = '123456789';
> $sPattern = '/(\d+)(\d{2})(\d{2})$/';
> preg_match($sPattern, $iNumber, $aMatches);
>
> Then $aMatches contains:
>
> Array
> (
> [0] => 123456789
> [1] => 12345
> [2] => 67
> [3] => 89
> )
>
> The regexp pattern /(\d+)(\d{2})(\d{2})$/ means:
>
> (one or more digits) (two digits) (two digits) [end of string]
>
> preg_match
> http://ca3.php.net/manual/en/function.preg-match.php
>
> Pattern Syntax
> http://ca3.php.net/manual/en/reference.pcre.pattern.syntax.php
>
> Regards,
> Paul
--
---
Børge
Kennel Arivene
http://www.arivene.net
---
--- End Message ---
--- Begin Message ---
Børge Holen wrote:
Oh this was good.
I added a while loop to insert extra strings "0" in front of the number to add
if the string is less than 5 chars short.
sprintf is your friend here, no need to use a loop.
sprintf('%05d', '1234');
--
Postgresql & php tutorials
http://www.designmagick.com/
--- End Message ---
--- Begin Message ---
On Thu, 2006-11-16 at 10:47 +1100, Chris wrote:
> Børge Holen wrote:
> > Oh this was good.
> > I added a while loop to insert extra strings "0" in front of the number to
> > add
> > if the string is less than 5 chars short.
>
> sprintf is your friend here, no need to use a loop.
>
> sprintf('%05d', '1234');
No need to use a sledgehammer when a screwdriver will suffice:
<?php
echo str_pad( '1234', 5, '0', STR_PAD_LEFT )
?>
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 Thu, 2006-11-16 at 10:47 +1100, Chris wrote:
Børge Holen wrote:
Oh this was good.
I added a while loop to insert extra strings "0" in front of the number to add
if the string is less than 5 chars short.
sprintf is your friend here, no need to use a loop.
sprintf('%05d', '1234');
No need to use a sledgehammer when a screwdriver will suffice:
<?php
echo str_pad( '1234', 5, '0', STR_PAD_LEFT )
?>
I knew there was another way ;)
Thanks for the reminder..
--
Postgresql & php tutorials
http://www.designmagick.com/
--- End Message ---
--- Begin Message ---
At 11/15/2006 02:06 PM, Børge Holen wrote:
Oh this was good.
I added a while loop to insert extra strings "0"
in front of the number to add
if the string is less than 5 chars short.
I forgot to mentinon that the string actually could be shorter (just found
out) and the code didn't work with fewer than 5 char strings.
But now is rocks.
Hey Børge,
If you need to left-pad with zeroes, PHP comes to the rescue:
http://php.net/str_pad
However, if you're using the regular expression
method then you might not need to pad the
number. You can change the pattern from this:
/(\d+)(\d{2})(\d{2})$/'
to this:
/(\d*)(\d{2})(\d{2})$/'
so it won't require any digits before the final two pairs.
* 0 or more quantifier
+ 1 or more quantifier
http://ca.php.net/manual/en/reference.pcre.pattern.syntax.php
Paul
--- End Message ---
--- Begin Message ---
bruce wrote:
hi chris...
for the initial post, it does/did matter for register_globals to be on/off.
in your reply, you use a $_GET[..] for the $path var. in the initial post
that i saw, (which i replied to), the $path var was simply used, without the
$_GET[..]. it's my understanding (recollection) that if the register_globals
is on, then php will automatically generate and fill vars based on the query
var. whereas, if the register_globals is off, the app has to specifically
'assign' the var via the $GET/$POST...
feel free to correct if something was/is missed. other than that, what you
have stated is completely correct as i understand php to work.
Fair enough. My point was it's not *just* a register-globals problem,
rather it can also be a simple "trusting" issue (ie you're trusting the
user data rather than checking it).
--
Postgresql & php tutorials
http://www.designmagick.com/
--- End Message ---
--- Begin Message ---
I've run into this sort of issue a few times before, and never found a good
solution. Now a client has been hit with it and is asking for a solution,
and I'm not convinced there is one. :-)
Client has a large MS SQL database with lots of data. Some of that data
includes "smart quotes", aka curly quotes, but not real ones. They're the MS
Word character encoding standards? What's that?" smart quotes. On their old
setup (SQL Server 2k, OpenLink ODBC driver, IIS, PHP 4.0.6), they actually
worked just fine. On our old devel setup (the same but with a different ODBC
driver), it worked fine.
On our new devel setup (SQL Server 2k, OpenTDS ODBC driver, Apache, PHP
5.1.6), it works fine. On their new live setup, however, (same, but again
not sure of the ODBC driver) they're getting the dreaded squares or question
marks or accented characters that signify a garbled smart quote. I know
they're not unicode characters because Windows, the DB server, and the driver
are all set to either UTF-8 or UTF-16.
We've tried eliminating middle-men to no avail. I've also tried doing a
find-replace on the smart quote characters before they're inserted into the
database, copying and pasting them from Word, and PHP skips right past them
and enters them into the database.
All we're left with is MAYBE telling them to dry a different ODBC driver or
else fixing the data by hand. I don't like either option, myself. Does
anyone have any better ideas to suggest? Any idea what those smart quotes
actually are, and if they exist in ANY valid character set other than Word
itself?
--
Larry Garfield AIM: LOLG42
[EMAIL PROTECTED] ICQ: 6817012
"If nature has made any one thing less susceptible than all others of
exclusive property, it is the action of the thinking power called an idea,
which an individual may exclusively possess as long as he keeps it to
himself; but the moment it is divulged, it forces itself into the possession
of every one, and the receiver cannot dispossess himself of it." -- Thomas
Jefferson
--- End Message ---
--- Begin Message ---
On Wed, 2006-11-15 at 20:36 -0600, Larry Garfield wrote:
> I've run into this sort of issue a few times before, and never found a good
> solution. Now a client has been hit with it and is asking for a solution,
> and I'm not convinced there is one. :-)
>
> Client has a large MS SQL database with lots of data. Some of that data
> includes "smart quotes", aka curly quotes, but not real ones. They're the MS
> Word character encoding standards? What's that?" smart quotes. On their old
> setup (SQL Server 2k, OpenLink ODBC driver, IIS, PHP 4.0.6), they actually
> worked just fine. On our old devel setup (the same but with a different ODBC
> driver), it worked fine.
>
> On our new devel setup (SQL Server 2k, OpenTDS ODBC driver, Apache, PHP
> 5.1.6), it works fine. On their new live setup, however, (same, but again
> not sure of the ODBC driver) they're getting the dreaded squares or question
> marks or accented characters that signify a garbled smart quote. I know
> they're not unicode characters because Windows, the DB server, and the driver
> are all set to either UTF-8 or UTF-16.
>
> We've tried eliminating middle-men to no avail. I've also tried doing a
> find-replace on the smart quote characters before they're inserted into the
> database, copying and pasting them from Word, and PHP skips right past them
> and enters them into the database.
>
> All we're left with is MAYBE telling them to dry a different ODBC driver or
> else fixing the data by hand. I don't like either option, myself. Does
> anyone have any better ideas to suggest? Any idea what those smart quotes
> actually are, and if they exist in ANY valid character set other than Word
> itself?
There's a few different charsets that support them. Either way, can you
open up some content that has them using a hex editor and tell us the
hex codes for the bytes? That will help determine what charset.
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 Wed, 2006-11-15 at 20:36 -0600, Larry Garfield wrote:
>
>
>>I've run into this sort of issue a few times before, and never found a good
>>solution. Now a client has been hit with it and is asking for a solution,
>>and I'm not convinced there is one. :-)
>>
>>Client has a large MS SQL database with lots of data. Some of that data
>>includes "smart quotes", aka curly quotes, but not real ones. They're the MS
>>Word character encoding standards? What's that?" smart quotes. On their old
>>setup (SQL Server 2k, OpenLink ODBC driver, IIS, PHP 4.0.6), they actually
>>worked just fine. On our old devel setup (the same but with a different ODBC
>>driver), it worked fine.
>>
>>On our new devel setup (SQL Server 2k, OpenTDS ODBC driver, Apache, PHP
>>5.1.6), it works fine. On their new live setup, however, (same, but again
>>not sure of the ODBC driver) they're getting the dreaded squares or question
>>marks or accented characters that signify a garbled smart quote. I know
>>they're not unicode characters because Windows, the DB server, and the driver
>>are all set to either UTF-8 or UTF-16.
>>
>>We've tried eliminating middle-men to no avail. I've also tried doing a
>>find-replace on the smart quote characters before they're inserted into the
>>database, copying and pasting them from Word, and PHP skips right past them
>>and enters them into the database.
>>
>>All we're left with is MAYBE telling them to dry a different ODBC driver or
>>else fixing the data by hand. I don't like either option, myself. Does
>>anyone have any better ideas to suggest? Any idea what those smart quotes
>>actually are, and if they exist in ANY valid character set other than Word
>>itself?
>>
>>
>
>There's a few different charsets that support them. Either way, can you
>open up some content that has them using a hex editor and tell us the
>hex codes for the bytes? That will help determine what charset.
>
>Cheers,
>Rob.
>
>
John Walker's insight might be a good lead on some more information on
exactly what these are, even if it doesn't directly solve the problem.
I can only guess that their 'smart quotes' exported to HTML from Office
apps are the same 'smart quotes' in your database... who knows :p
http://www.fourmilab.ch/webtools/demoroniser/
Travis Doherty
--- End Message ---