[PHP] Re: XML, what is that supposed to do?

2001-01-16 Thread Terrence Chay

on 1/16/00 9:38 AM, Brandon Orther at [EMAIL PROTECTED] wrote:

> I have seen a lot of people ask for XML support for PHP.  I was wondering
> what it does that makes it good for PHP.

That's a hard one to answer--I'll try anyway. I'm sorry if it sounds a
bit simple-minded but that's the sort of person I am ;-).

XML stands for eXtensible Markup Language. It's an attempt by both large
corporations (notably Microsoft, Oracle, and IBM) as well as the standards
organizations (notable the W3C) to create a "lingua franca" for the web. A
lot of understanding it has first to have a slightly different perspective
of what we mean by "the internet" and "the web".

First when most people say "the internet" now, they pretty much mean
"the web" and e-mail. When people say "the web" they mean HTTP and HTML
(with a little SSL thrown in for e-commerce). HTTP is the transport protocol
(how it is delivered) and HTML is the markup language (the message). XML
attempts to replace and supersede HTML without saying anything about HTTP
(though one can assume that most of the delivery will be done via HTTP, much
to the chagrin of many security administrators who depend on firewalls).

XML is a markup language like HTML. Unlike HTML, the markup language is
extensible (basically think of it as saying you can define your own tags and
attributes). This means you can make descriptive tags such as

Joe BlogsSATs - How to be
beaten by the systemTest preparation

Which looks a lot like HTML but isn't. Interestingly, the tags are
descriptive of the content which beats the hell out of UN/EDIFACT if you've
ever had to do any work for big business. Other differences are the rules
are more rigid than HTML: all tags must close, all attributes must be
quoted, all reserved characters must be escaped properly, all tags and
attributes are case sensitive. The default format for display is double byte
encoded characters (UTF-16 / UNICODE) (Note: The default used by PHP seems
to be UTF-8 so you should change it to that charset in the XML directives
line).-
So basically what you have when you are done is a text based
hierarchical data structure that's extensible and machine readable. That's
all XML is.

Now the things you can do with it. Obviously for one I can use this to
serialize objects in PHP very easily since I can store objects in XML
representation which is just a string to be saved. The WDDX module does that
in some standard way.

A note about standards. Since XML is extensible, there is a need to be
specified so that I can communicate with you and we understand each other.
XML is really more like a markup language FORMAT than a language (or seen
another way, it's a standard but not a specification). There are various
specifications and attempts at specifications out there and are usually
referred to as DTDs, Document Type Definitions, or Schema. It used to be you
specified your Schema in another markup language called SGML but then some
people figured if XML is so extensible you should be able to specify your
own Schema in an Schema language which itself is XML. This is known, not
surprisingly, as XML Schema. Which represents another thing you can do with
XML: Use XML to specify XML data formats.

A useful one for web programmers right now is you can use XML to turn
XML into other XML formats. This is done through XSL-T (eXtensible
Stylesheet Language - Transform) which is built into a PHP module called
Sablotron (Side Note: I couldn't compile Sablotron 0.50 in PHP yet, it
failes during the linking step in Apache and claims that it can't find some
library that is in Expat). Sablotron (and many XML-T parsers) is a little
robust in that you can use it to transform it into HTML and text too. This
warrants a bit larger description...

Basically XSL works by taking an input XML file (we'll call this the
"data store") and using another XML file written using the XSL specification
(we'll call this the "rules file") to create another file in a different XML
format (we'll  all this the "presentation file"). Obviously when the
presentation file is in XML, we can chain another rules file to it to make
another presentation file and so on. XSLT parsers such as Sablotron allow us
to do just that. Why is this powerful? The best way is through examples

(1) Our company builds a search engine that goes out and does a
real-time travel comparison engine of 25 separate travel websites. Given
that each search does this, we offload this to a business rules server that
creates this and returns the results. Because we add sites and features
almost at will, this messaging standard had to be extensible. The webserver
has to communicate with this business rules server and understand it. A
stylesheet can ensure that the message that gets sent to the web server is
always in line with what the webserver can understand even if we upgrade our
features on the business rules server.

(2) Furthermore, we have some nasty internal busi

Re: [PHP] Can I fork a PHP thread?

2001-01-18 Thread Terrence Chay

on 1/17/01 10:12 AM, Chris Lee at [EMAIL PROTECTED] wrote:
>> There are occasions when I'd like to execute some long-running task
>> in the background, in response to some user action.  It seems that

> Im nearly posative this isnt what your looking for, but I thought I would
> see if maybe it was :)
 
> compile php as a cgi so you can run it from the command prompt. then just
> run the php file from the command prompt through exec ()

>  exec("php -q somephpfile.php &");
> ?>

If you want the thing to always complete then you'll need to nohup the
exec call. Otherwise, the "php -q" would be a child process of the php
module and will be killed when the web page script quits (assuming you
compiled PHP as a module (shared or otherwise)). That kill would occur when
the it finishes outputting the page or the browser has closed the connection
(moves onto another page).

Another note is I believe exec() returns the last line of the output of
the command. This means that you'll see the browser stuck on the last
flush() before function handle_some_action() until you reach the timeout
specified in php.ini (usually 30 seconds) as the php module will need to
wait for the command to complete before it returns a line. popen() would
also do this (I believe the pipe blocks until the output is filled). So for
this to work you've got to set it so that it returns immediately...
something like..
  "nohup php -q somephpfile.php >&/dev/null &"
(or somesuch).

>> In the cases I'd like to do this, I can manage synchronization
>> externally...
>> (i.e., implement join by waiting for a /tmp file to appear or
>> something),
>> so I'm not asking for a join, or any sychronization facilities.

I'm not too certain what is meant by this, so I don't know if what I was
any help. :-)

Note that the "somephpfile.php" does not need to have set_time_out(0)
because when php is run from the command line it will keep executing even
after the timer has expired. I don't know if this is a bug or a feature.

Take care,

terry

-- 
terry chay, Director of Engineering, 
QIXO /kick.so/ - Integrating Many Travel Web Sites Into One
W: 1.408.394-8102 F:1.408.516.9090M: 1.408.314.0717
E-Mail:  ICQ: 16069322
PGP Fingerprint: 6DCF 1634 547C 935D 4912  2A44 A4A2 79AB DFFF F110 


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] zend ide & debugger

2001-01-26 Thread Terrence Chay

1-month commercial license ($90).

Download wasn't too bad. I haven't had a chance to check out the Zend
LaunchPad. The installation (Apache Linux PHP 4.04pl1+patches) took me about
30 minutes for client and server which included the wait on the license key.
It took us another day to put up because there is no mention that the
debugger doesn't work with the optimizer on. Zend customer service fixed
that though.

The IDE is pretty nice. Startup (Windows version through Samba) takes a
long time and there are still some crashing issues. It's nowhere near as
spry as PHPEd but we're talking about a integrated debugger. The interface
is Swing-based as near as I can tell and my main gripe besides the speed is
I can't use the scroll wheel. It still crashes a bunch (not sure if it's the
debugger or what). I passed it off to an engineer so I can't comment
further. (He's having trouble getting it to recognize the include files.
Anyone have a tip?)

BTW, the debugger has a browser mode, it sends off some codes in a the
get string of the URL. I didn't test it.

Some people like source level debuggers and I think it's a good tool
especially considering all the headaches Nexidion Designer gave us a while
back. Personally, the last time I used a debugger, I was making a calculator
using an 80186 (the debugger was a hardware one the size of two coffee table
books stacked next to each other) so obviously I never got used to them. If
you come from the Boreland C/Visual Studio world, I suppose you might find
the IDE essential. If my engineers ever use it, I'll get the company to
spring for a license or 5.

Take care,

terry

-- 
terry chay, Director of Engineering, 
QIXO /kick.so/ - Integrating Many Travel Web Sites Into One
W: 1.408.394-8102 F:1.408.516.9090M: 1.408.314.0717
E-Mail:  ICQ: 16069322
PGP Fingerprint: 6DCF 1634 547C 935D 4912  2A44 A4A2 79AB DFFF F110 


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] To the question about scripts running after a connection close...

2001-08-05 Thread terrence chay

I'm sorry, I accidentally deleted the original e-mail.

By default the script will keep running even after a user presses the 
stop button on their client. This can be determined by using 
ini_get('ignor_user_abort') and checking the value. (NB: I'm not sure what 
the value is, the documentation defines it to be a string, but the 
settings seem to imply it is a boolean).

If you want a more ASP-like functionality (stops outputting when other 
side closes connection) then call the function


I hope this helps,

Take care,

terry chay

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Persistent connections and transactions

2001-01-26 Thread Terrence Chay

on 1/25/01 11:49 AM, Frank Joerdens at [EMAIL PROTECTED] wrote:

> On Thu, Jan 25, 2001 at 04:04:24PM -0300, Martin A. Marques wrote:
> [ . . . ]
>> Of course. But the persistent connection are not working as the manuals say
>> they should work.

> It appears this riddle has been solved: From a post by Adam Lang on
> pgsql-php on Dec 8:

> 
> Well, there's a problem with PHP's [mis]documentation. First of all,
> it counts open DB connections not on per-webserver, but on
> per-process/thread basis.
> The default PHP config file has the limits of persistent and
> non-persistent connections set to -1 (no limit)... Setting it to
> some (supposedly) reasonable value (like, 50) accomplishes nothing: you
> should multiply 50 by the number of webserver processes/threads. There
> can be lots of them... :[
> And then there comes PHP's "logic": if I can just open the new
> connection, why bother reusing the old one? And thus Postgres backends
> start multiplying like rabbits, eventually reaching the limit... :[
> You should set a reasonable limit on number of open persistent
> connections (like 1, maybe 2 or 3), only then PHP will actually reuse
> them. My webserver now works with such setup and there are no more
> problems with pg_pconnect().
> 

This sounds very confusing. Does anyone know how pconnects are pooled?
For instance this post implies that pconnects might be pooled on a per httpd
child process which would be silly as hell because httpd processes surely
"spawn like rabbits" and all of them would eventually cycle to a web page
that would generate a persistant connection.

How are pconnects released into the pool? If the former case there is no
pool so no reason to release. In the latter case, there should be a
procedure I could call (like pg_pclose()?) which would not close the
connection but simply release it back into a pool for another pconnect() of
a different httpd to call. This could especially be useful for long-running
scripts.

How are pconnects terminated? Is there a time to live on them? Are they
never dying unless the child dies? The load on most web servers often varys
by a factor of 8 during the day and 2 between weekends and weekdays. Without
pconnect termination, one would accumulate a lot of idle persistent
connections. Ideally, PHP would manage it.

It's not like the pconnect() HAS to be on a per-child business. In
theory pconnects could be put into a shared memory segment and pooled. A
time to live of 30 minutes and configurable in php.ini would handle most web
server/db interaction and ensure that you don't have say 115 open
connections to the database with only 4 being used at a time.

I don't know how PHP is programmed or how the PosgreSQL extension was
made so I really have no clue here.

terry 

-- 
terry chay, Director of Engineering, 
QIXO /kick.so/ - Integrating Many Travel Web Sites Into One
W: 1.408.394-8102 F:1.408.516.9090M: 1.408.314.0717
E-Mail:  ICQ: 16069322
PGP Fingerprint: 6DCF 1634 547C 935D 4912  2A44 A4A2 79AB DFFF F110 


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Zend hit (Encoder price)

2001-01-26 Thread Terrence Chay

on 1/26/01 1:36 AM, Richard Lynch at [EMAIL PROTECTED] wrote:

>> If there are some things you really need to hide, and perhaps also really
>> need to make fast, then write yourself a PHP extension in C that
 
> I dunno...  Once you start writing chunks of it in C code, it doesn't really
> seem like a script to me...
>...
> But at that point, it starts to look a lot more like a C program with some
> interface widgets in PHP, rather than a PHP script really.

Actually Microsoft does exactly just this with Active Server Pages. Most
of the functionality in Active Server Pages are done through dynamically
loaded component libraries (ActiveX/COM). It works fairly well as you can
get some high quality commercial components. But it does hurt too because
you don't have very much built into ASP itself (in fact, very little is.
Almost everything is COM) and you find that ASP + default COM may be missing
some key stuff you might need (like file opens on URLs, file upload, etc)
and is built into PHP.

Microsoft does offer one thing over the "chunk of C code". COM can be
written in Visual Basic and even VBScript encased XML (though why anyone
would want to do this would have me a bit confused as ASP is written in
VBScript). I'd imagine you could write COM very easily in C# which is a lot
like Java. So there are a lot more options right now as well as better
developer tools (and support). But you pay for it. ;-)

Most people don't create COM. Most people purchase them or use the
default COM that Microsoft provides (A file system object, a browser object,
a database object, etc.). There are also a lot of stuff that might as well
be "default COM" because they're part of a product that everyone installs in
their computer (for instance, an XML parser, or Excel's ability to render
graphs), these too can be instantiated from within ASP.

All this causes interesting problems when the developer goes out of
business or decided to stop supporting it.

(Side note: Apparently PHP for Windows can instantiate COM. I'd imagine
most of the ASP2PHP translator would depend on this fact?)

Take care,

terry
-- 
terry chay, Director of Engineering, 
QIXO /kick.so/ - Integrating Many Travel Web Sites Into One
W: 1.408.394-8102 F:1.408.516.9090M: 1.408.314.0717
E-Mail:  ICQ: 16069322
PGP Fingerprint: 6DCF 1634 547C 935D 4912  2A44 A4A2 79AB DFFF F110 


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Pricing for PHP programming???

2001-02-01 Thread Terrence Chay

We should be prudent when discussing how much we charge for programming.
I'm no lawyer but I believe it's okay to discuss hypotheticals, histories,
and such, but remember that discussing wage rates may run against anti-trust
regulation as evidence of collusion (at least in the United States).

Having said that, I seriously doubt we'd have the DOJ banging down on
listers. And I find this topic honest and interesting, even though it
doesn't concern me.

Besides, sometimes I think that PHP is so easy to learn that we should
be considered unskilled labor ;-)

Take care,

terry

-- 
terry chay, Director of Engineering, 
QIXO /kick.so/ - Integrating Many Travel Web Sites Into One
W: 1.408.394-8102 F:1.408.516.9090M: 1.408.314.0717
E-Mail:  ICQ: 16069322
PGP Fingerprint: 6DCF 1634 547C 935D 4912  2A44 A4A2 79AB DFFF F110 


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]