php-general Digest 8 Feb 2009 14:35:26 -0000 Issue 5947
Topics (messages 287915 through 287920):
Re: Sending XML requests as raw post data
287915 by: Nathan Rixham
287916 by: Nathan Rixham
Re: Reg-ex help
287917 by: Craige Leeder
Seeking PHP Work in Chicago or Telecommute
287918 by: Richard Lynch
Re: Speed Opinion
287919 by: Martin ZvarĂk
PHP usage stats
287920 by: Richard Heyes
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 ---
Marc Steinert wrote:
Hi there!
The software I'm maintaining uses $HTTP_RAW_POST_DATA to receive XML
requests, posted by some client written in C#.
Now I need to write a PHP client that posts XML requests the same way as
the C# client, so that the posted data is stored in $HTTP_RAW_POST_DATA,
too.
I tried to use curl to match my needs, but failed to establish a
connection with the following code:
$header[] = "Host: ".$host;
$header[] = "MIME-Version: 1.0";
$header[] = "Accept: text/xml";
$header[] = "Content-length: ".strlen($xmlRequest);
$header[] = "Cache-Control: no-cache";
$header[] = "Connection: close \r\n";
$header[] = $xmlRequest; // Contains the XML request
curl_setopt($curl, CURLOPT_URL,self::BASE_URL);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_TIMEOUT, 4);
curl_setopt($curl, CURLOPT_CUSTOMREQUEST,'POST');
curl_setopt($curl, CURLOPT_HTTPHEADER, $header);
// Dispatch request and read answer
$response = curl_exec($curl); // returns false
Thanks for your help.
Greetings from Germany
Marc
i think..
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $xmlhere );
--- End Message ---
--- Begin Message ---
Marc Steinert wrote:
Hi there!
The software I'm maintaining uses $HTTP_RAW_POST_DATA to receive XML
requests, posted by some client written in C#.
Now I need to write a PHP client that posts XML requests the same way as
the C# client, so that the posted data is stored in $HTTP_RAW_POST_DATA,
too.
I tried to use curl to match my needs, but failed to establish a
connection with the following code:
$header[] = "Host: ".$host;
$header[] = "MIME-Version: 1.0";
$header[] = "Accept: text/xml";
$header[] = "Content-length: ".strlen($xmlRequest);
$header[] = "Cache-Control: no-cache";
$header[] = "Connection: close \r\n";
$header[] = $xmlRequest; // Contains the XML request
curl_setopt($curl, CURLOPT_URL,self::BASE_URL);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_TIMEOUT, 4);
curl_setopt($curl, CURLOPT_CUSTOMREQUEST,'POST');
curl_setopt($curl, CURLOPT_HTTPHEADER, $header);
// Dispatch request and read answer
$response = curl_exec($curl); // returns false
Thanks for your help.
Greetings from Germany
Marc
and nearly forgot, you can loose all of those headers, half the ones you
specified are for responses not requests anyways :p
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, self::BASE_URL);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, $xmlRequest);
curl_setopt($curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
curl_setopt($curl, CURLINFO_HEADER_OUT, 1);
$response = curl_exec($curl);
--- End Message ---
--- Begin Message ---
Thanks!
That's a big help.
- Craige
Jim Lucas wrote:
Craige Leeder wrote:
Hey guys,
I'm trying to write a regular expression to match a tag for my
frameworks template engine. I seem to be having some trouble. The
expression should match:
{:seg 'segname':}
{:seg 'segname' cache:}
What I have is...
$fSegRegEx = "#\{:seg \'[a-z0-9\-\_]{3,}\'( cache)?:\}#i";
Which when run against my test data, seems to match:
"{:seg 'segname' cache:}"
" cache"
Thanks guys. This has been bugging me for a couple days.
- Craige
I used some of your code, but try this variant on for size.
<plaintext>
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
$dummyData = <<<DATA
<html>
<body>
<h1>{:seg 'title':}</h1>
<h1>{:seg 'title' cache:}</h1>
</body>
</html>
DATA;
# For arguments sake, I'll provide the whole code snippet...
$fSegRegEx = "|\{:(seg) \'([a-z0-9\-\_]{3,})\'\s?(cache)?:\}|i";
preg_match_all($fSegRegEx, $dummyData, $faSegMatches, PREG_SET_ORDER);
print_r($faSegMatches);
?>
Not sure what your input is going to be (HTML, XML, etc...) so I used
HTML
Anyways, output from the above code is this:
<plaintext>
Array
(
[0] => Array
(
[0] => {:seg 'title':}
[1] => seg
[2] => title
)
[1] => Array
(
[0] => {:seg 'title' cache:}
[1] => seg
[2] => title
[3] => cache
)
)
Hope this starts you down the right path.
--- End Message ---
--- Begin Message ---
I figure if job postings are okay, then so are job requests, right? :-)
I'm looking for PHP work in Chicago or telecommuting.
My resume is here:
http://l-i-e.com/resume.htm
--
Some people ask for gifts here.
I just want you to buy an Indie CD for yourself:
http://cdbaby.com/search/from/lynch
--- End Message ---
--- Begin Message ---
Nathan Rixham napsal(a):
Ashley Sheridan wrote:
On Thu, 2009-02-05 at 09:44 +1100, Chris wrote:
PHP wrote:
Hi all,
I am seeking some knowledge, hopefully I explain this right.
I am wondering what you think is faster.
Say you have 1000 records from 2 different tables that you need to
get from a MySQL database.
A simple table will be displayed for each record, the second table
contains related info for each record in table 1.
Is if faster to just read all the records from both tables into two
arrays, then use php to go through the array for table 1 and figure
out what records from table 2 are related.
Or, you dump all the data in table 1 into an array, then as you go
through each record you make a database query to table 2.
Make the db do it.
PS:
I know I can use a join, but I find anytime I use a join, the
database query is extremely slow, I have tried it for each version
of mysql and php for the last few years. The delay difference is in
the order of 100x slower or more.
Then you're missing indexes or something, I've joined tables with
hundreds of thousands of records and it's very fast.
--
Postgresql & php tutorials
http://www.designmagick.com/
I've used joins on tables with millions of rows, and it's still not been
too slow to use. Admittedly it was an MSSQL database, which I've always
found to be slower, but MySQL was built to be a relational database, and
can handle many many millions of records quite happily. The slowdown you
experienced is either not using indexes on tables, or the way you were
displaying/manipulating those results from within PHP.
Ash
www.ashleysheridan.co.uk
and if you use spatial indexes and points instead of integers you can
join on the biggest of databases with literally no perfomance hit, same
speed regardless of table size :p (plus cos a point has two values you
can use one for id and the other for timestamp ;)
regards
ps: i've said this many times before, but not for like 6 months so time
for another reminder
"MySQL supports spatial extensions to allow the generation, storage, and
analysis of geographic features."
So, I use spatial indexes when creating a geographic map? Is it good for
anything else?
--- End Message ---
--- Begin Message ---
Hi,
Can anyone point out some general statistics on PHP usage compared to
other server languages? I've tried Netcraft, but they only appear (or
I've only found) to have statistics on the httpd server used.
Thanks.
--
Richard Heyes
HTML5 Canvas graphing for Firefox, Chrome, Opera and Safari:
http://www.rgraph.org (Updated January 31st)
--- End Message ---