php-general Digest 17 Sep 2005 15:22:21 -0000 Issue 3687

Topics (messages 222552 through 222574):

Re: PHP combined with JAVA
        222552 by: Nathan Tobik

Re: [Off] How much time should this take?
        222553 by: John Nichel
        222554 by: 2wsxdr5
        222560 by: Brad Dameron
        222561 by: John Nichel

imap_open
        222555 by: Joachim Person
        222556 by: Joachim Person
        222558 by: John Nichel
        222573 by: Joachim Person

Warning: imap_open(): Couldn't open stream
        222557 by: Joachim Person
        222559 by: John Nichel

Re: Quick Poll: PHP 4 / 5
        222562 by: Jasper Bryant-Greene
        222564 by: Manuel Lemos
        222568 by: leaf
        222570 by: Jasper Bryant-Greene
        222571 by: Robert Cummings
        222574 by: leaf

Re: PDO for PHP 4 (was Re: Quick Poll: PHP 4 / 5)
        222563 by: Manuel Lemos

Re: email validation regex
        222565 by: Robert Paul

Re: Qt like Signals and Slots (Idea + Implementation)
        222566 by: Robert Paul

Encoding or obfuscating tool
        222567 by: Anas Mughal

Re: xml first special char
        222569 by: leaf

Re: PATH_INFO/PATH_TRANSLATED
        222572 by: Infoton - Nilesh Narkhede

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 ---
I would approach this problem in one of two ways

1. put all the values from the Java User object into PHP variables and store 
those in the session.  You might have to deal with serialization issues as 
mentioned below, but I think copying to PHP would get rid of this issue.

2. It almost sounds like he's trying to accomplish data persistence with the 
Java class.  At this point I would recommend looking into using Hibernate and 
PHP which would accomplish this, or look at some JavaBeans/Servlet solution 
which would negate the need for PHP. Most people accomplish persistence with a 
DB, like mentioned below the PHP/Java bridge is torn down after the page is 
done.

As a side note I know with the PHP-Java Bridge on sourceforge you can setup the 
JVM so that it won't deconstruct after each page execution.  This saves the 
expense of loading a JVM each time. 

To me the real advantage of PHP/Java is being able to use presentation code 
written in PHP with objects that are in Java.  The heavy lifting is in the Java 
code and the PHP just presents the data.  If more interaction than that is 
required I'd seriously look at the whole servlet/bean/j2ee/ejb route. 

Nate Tobik
(412)661-5700 x206
VigilantMinds

-----Original Message-----
From: Oliver Grätz [mailto:[EMAIL PROTECTED] 
Sent: Thursday, September 15, 2005 8:40 PM
To: [email protected]
Subject: [PHP] Re: PHP combined with JAVA

If I read this correctly then your question is in no way JAVA-specific.
You want to instantiate an object (which you suppose to be of large size
and slow in instantiation) and save this object in the session during
page requests.

First of all, any data put in the session array will be serialized
(read: converted into a string containing all the data in this object).
This in itself is slow for large objects. A performance gain for large
objects through using a session isn't likely.

The second problem with this - and this is the point where JAVA kicks in
- not all data in objects is serializable. The Java-API of PHP is just
some kind of adapter to the Java system. If you serialize an adapter
object then your adapter is saved but not the Java object it uses
(because PHP has no control over it). Think of the Java API as some kind
of socket connection where you only see the stuff on your side (the
client side) and the JAVA object on the "server" side is not under your
control but just used.

What happens is: you save you adapter object and the script terminates.
The JAVA VM notices that an object is no longer referenced and it is
thrown away by the garbage collection.

What could you do? Well, you could use it the other way round (Servlet
uses PHP), because then you control the JAVA side. Or you still do it
the way you do it now but write some clever JAVA code that keeps running
and retains your objects. You give those objects a name known to both
the PHP and JAVA side and this name can be serialized. You can then
re-reference any object on the next page request by its name.

AllOLLi
____________
Jayne spits a large glob of saliva on his blade,
wipes it on his shirt, shining it.
"Could you NOT do that while we're.... ever!"
[Simon on firefly 09]

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

--- End Message ---
--- Begin Message ---
Iggep wrote:
John Nichel wrote:

Brian Dunning wrote:

I got a 12-hour invoice from a consultant who was tasked to do the following:

- Install a Red Hat machine from absolute scratch for PHP/MySQL/Apache

- Copy over some MySQL databases

- Have mod_rewrite working via htaccess, and have wildcard DNS

I realize there are a billion different variables - I don't know specifically what distribution he used, or any other variables - but what are the chances that his invoice is reasonable? Assume that he should know what he's doing without having to learn anything. Thanks...


Sounds about right. I just set up a box Tuesday....took me about 9 hours. Installed RHEL 3.0 AS, Apache 1.3.x, PHP 4.4.0, mod_perl, MySQL 4.0.x, CVS, etc. from scratch. Wednesday I took about 4 hours tweaking and locking down the box before I put it on the network.


How on earth could you take 9 hours to do this? Thats a ridiculously long time to do something such as this. Well, perhaps I could see that if you were fumbling around with no plan in mind. Just installing and then going over things as you thought of them. But a consultant who proffers to do this? No way. It shouldn't have taken even half of the time billed and probably 1-2 hours less than even that.

Well then, enlighten us as to the plan you have in mind, and how it will take you less than 4.5 hours.

--
John C. Nichel
ÜberGeek
KegWorks.com
716.856.9675
[EMAIL PROTECTED]

--- End Message ---
--- Begin Message ---
Wigs @Claw wrote:

Hi guys ,  sorry for responding if this message is a bit off topic!

Id have to say that you are assuming no glitches come into play with that response.

I just recently had to do a Red Hat install , with Apache , MySQL and the works. The install of Redhat ran into some issues with drivers on the older hardware , and this caused an obscene amount of time to the process.

That's why I said if you have a fast computer with *compatible* hardware"

And if you have *never* touched DNS , I doubt you would want to rely on a couple hours to figure it out and leave it.


probably true but I wouldn't charge a client for the time it took me to figure out something I should know before I take the job unless they specifically know and accept that condition a head of time.

Testing time also adds to the figure , and I think its quite possible that if there were hiccups ,


Most hiccups can be avoided if you make sure you know exactly what hardware you have and make sure it is compatible first.

and if this consultant did proper testing etc , it could be close to 12. But you know the job more in depth than me.


Testing would add time but with the condition's I listed I still think it could be done in 6 hours.

--
Chris W

Gift Giving Made Easy
Get the gifts you want & give the gifts they want
http://thewishzone.com

--- End Message ---
--- Begin Message ---
On Fri, 2005-09-16 at 15:33 -0400, John Nichel wrote:
> The OS install will take between 1 - 3 hours, depending on the machine. 
>   Setting up mod_rewrite to work via .htaccess is simple; compile it in, 
> and make sure it's allowed to work via .htaccess in the httpd.conf.  Not 
> really sure what the OP meant by wildcard DNS, but if it was just 
> *.mydomain.com, the zone file nor the Apache config are all that tough. 
>   Copying over DB's...fast as the machine can copy.  These are all the 
> easy, quick tasks.
> 
> Building Apache/PHP can take some time depending on what you want 
> included.  Vanilla installs of the two I can do in under 30 minutes, but 
> once you start including modules, you may or may not have to install 
> other software to meet the dependencies of those modules.  Then there's 
> whether or not he wants SSL, mm, or other modules in Apache.  And we 
> haven't even touched on init scripts, or security...that's all part of 
> getting this stuff up and running.  No offense, but if someone's doing 
> this in 6 hours, I would be worried about the job not being complete.
> 

This is not Windows we are talking about where you have to wait for each
reboot. And then reboot again and again after patching. I can do a full
Fedora Core 4/SuSe Pro 9.3/SuSe Enterprise 9 install in under and hour.
Add another 30 minutes for updates, due to my T1 slow download speeds. 

I've been following this and I can say for a fact this could be done in
6 hours or less. And guarantee a secure server. How do I know? Because I
build these configurations almost daily. If you get stuck with init
scripts there's something wrong. Maybe you should man "chkconfig".

Brad Dameron
Senior Systems Administrator
SeaTab Software

--- End Message ---
--- Begin Message ---
Brad Dameron wrote:
On Fri, 2005-09-16 at 15:33 -0400, John Nichel wrote:

The OS install will take between 1 - 3 hours, depending on the machine. Setting up mod_rewrite to work via .htaccess is simple; compile it in, and make sure it's allowed to work via .htaccess in the httpd.conf. Not really sure what the OP meant by wildcard DNS, but if it was just *.mydomain.com, the zone file nor the Apache config are all that tough. Copying over DB's...fast as the machine can copy. These are all the easy, quick tasks.

Building Apache/PHP can take some time depending on what you want included. Vanilla installs of the two I can do in under 30 minutes, but once you start including modules, you may or may not have to install other software to meet the dependencies of those modules. Then there's whether or not he wants SSL, mm, or other modules in Apache. And we haven't even touched on init scripts, or security...that's all part of getting this stuff up and running. No offense, but if someone's doing this in 6 hours, I would be worried about the job not being complete.



This is not Windows we are talking about where you have to wait for each
reboot. And then reboot again and again after patching. I can do a full
Fedora Core 4/SuSe Pro 9.3/SuSe Enterprise 9 install in under and hour.
Add another 30 minutes for updates, due to my T1 slow download speeds.

And now you have a vanilla rpm install of all of the software. *I* wouldn't hire a person to do the job for me if that's what I'm going to get. YMMV

I've been following this and I can say for a fact this could be done in
6 hours or less. And guarantee a secure server. How do I know? Because I
build these configurations almost daily. If you get stuck with init
scripts there's something wrong. Maybe you should man "chkconfig".

I didn't say anything about getting 'stuck with init'. I pointed it out as another thing which has to be done in an install. If you're building this almost daily, maybe you should look into making yourself an image.

--
John C. Nichel
ÜberGeek
KegWorks.com
716.856.9675
[EMAIL PROTECTED]

--- End Message ---
--- Begin Message ---
I tried to make the simple program

<?php
$mbox = imap_open("{imap.liu.se:993}", "joape382", "WapiSse7");

echo "<h1>Mailboxes</h1>\n";
$folders = imap_listmailbox($mbox, "{imap.liu.se:993}", "*");

if ($folders == false) {
   echo "Call failed<br />\n";
} else {
   foreach ($folders as $val) {
       echo $val . "<br />\n";
   }
}

echo "<h1>Headers in INBOX</h1>\n";
$headers = imap_headers($mbox);

if ($headers == false) {
   echo "Call failed<br />\n";
} else {
   foreach ($headers as $val) {
       echo $val . "<br />\n";
   }
}

imap_close($mbox);
?>

given at http://se2.php.net/manual/sv/function.imap-open.php, but imap_open 
is not found. I'm running PHP 4.3.10. What is wrong?

--- End Message ---
--- Begin Message ---
What could be the cause of the error

 Warning: imap_open(): Couldn't open stream

? I have got the address and the port to the imap server right, but I think
that the imap server requires some sort of secure login. Could this be the
problem? If yes, how can it be solved? If no, what other causes could it be?

--- End Message ---
--- Begin Message ---
Joachim Person wrote:
I tried to make the simple program

<?php
$mbox = imap_open("{imap.liu.se:993}", "joape382", "WapiSse7");

echo "<h1>Mailboxes</h1>\n";
$folders = imap_listmailbox($mbox, "{imap.liu.se:993}", "*");

if ($folders == false) {
   echo "Call failed<br />\n";
} else {
   foreach ($folders as $val) {
       echo $val . "<br />\n";
   }
}

echo "<h1>Headers in INBOX</h1>\n";
$headers = imap_headers($mbox);

if ($headers == false) {
   echo "Call failed<br />\n";
} else {
   foreach ($headers as $val) {
       echo $val . "<br />\n";
   }
}

imap_close($mbox);
?>

given at http://se2.php.net/manual/sv/function.imap-open.php, but imap_open is not found. I'm running PHP 4.3.10. What is wrong?

Is IMAP support built into your install of PHP?  It's not on by default.

--
John C. Nichel
ÜberGeek
KegWorks.com
716.856.9675
[EMAIL PROTECTED]

--- End Message ---
--- Begin Message ---
"John Nichel" <[EMAIL PROTECTED]> skrev i meddelandet 
news:[EMAIL PROTECTED]
> Joachim Person wrote:
>> I tried to make the simple program
>>
>> <?php
>> $mbox = imap_open("{imap.liu.se:993}", "joape382", "fil");
>>
>> echo "<h1>Mailboxes</h1>\n";
>> $folders = imap_listmailbox($mbox, "{imap.liu.se:993}", "*");
>>
>> if ($folders == false) {
>>    echo "Call failed<br />\n";
>> } else {
>>    foreach ($folders as $val) {
>>        echo $val . "<br />\n";
>>    }
>> }
>>
>> echo "<h1>Headers in INBOX</h1>\n";
>> $headers = imap_headers($mbox);
>>
>> if ($headers == false) {
>>    echo "Call failed<br />\n";
>> } else {
>>    foreach ($headers as $val) {
>>        echo $val . "<br />\n";
>>    }
>> }
>>
>> imap_close($mbox);
>> ?>
>>
>> given at http://se2.php.net/manual/sv/function.imap-open.php, but 
>> imap_open is not found. I'm running PHP 4.3.10. What is wrong?
>
> Is IMAP support built into your install of PHP?  It's not on by default.
>
> -- 
> John C. Nichel
> ÜberGeek
> KegWorks.com
> 716.856.9675
> [EMAIL PROTECTED]

Thank you for your answer,
Yes, I have enabled it.
(I guess you got a few e-mails... sorry about that)
Regards,
Joachim 

--- End Message ---
--- Begin Message ---
What could be the cause of the error

 Warning: imap_open(): Couldn't open stream

? I have got the address and the port to the imap server right, but I think 
that the imap server requires some sort of secure login. Could this be the 
problem? If yes, how can it be solved? If no, what other causes could it be? 

--- End Message ---
--- Begin Message ---
Joachim Person wrote:
What could be the cause of the error

 Warning: imap_open(): Couldn't open stream

? I have got the address and the port to the imap server right, but I think that the imap server requires some sort of secure login. Could this be the problem? If yes, how can it be solved? If no, what other causes could it be?

http://www.google.com/search?q=%22Warning%3A+imap_open%28%29%3A+Couldn%27t+open+stream%22

--
John C. Nichel
ÜberGeek
KegWorks.com
716.856.9675
[EMAIL PROTECTED]

--- End Message ---
--- Begin Message ---
Stephen Leaf wrote:
So yes a bug. But for those that want to be able to grab only what we need. in my case array_pop's returned element. I don't wanna be hassled with the "are you sure you wanted to ignore part of what we did?" It's almost like every program asking "are you sure you wanted to close me?" everytime I get asked that I always think... "I did just click the X.. so.... Yah......."

But why use array_pop() to get the last element, when you know it's intended to shorten its passed array as well?

I mean, sure, it might take a few more lines of code to do it properly, but it has the advantage that whoever has to look at the code next might actually understand what's going on in your head.

$array = explode( ',', $some_string );
$last_element_pos = count( $array ) - 1;
$last_element = $array[$last_element_pos];

[ sure, you could put the count( $array ) - 1 as the array subscript but I was just extending it out for illustration... it's probably easier to understand later on anyway. ]

--
Jasper Bryant-Greene
Freelance web developer
http://jasper.bryant-greene.name/

--- End Message ---
--- Begin Message ---
Hello,

on 09/15/2005 09:32 AM Oliver Grätz said the following:
First of all, in many cases code reuse still is a myth. I hate to say it
but it's true. Then, a large potion of the PHP community hasn't even
heard of PEAR. Then, people definitely start projects from scratch. If
You don't know if you have any numbers to back "the large portion of the PHP community claim".

The proof is the sheer number of "this is *THE* PHP application
framework to use" sites on the internet. Some people don't like reusing
code, some evaluate those projects and decide against them. For my part,
before reinventing the wheel I always spend some time serching through
PEAR and the web but very often the available solutions don't fit my
needs. I simply suppose other developers tend to act the same way.

That is not proof of your claim. It is just your opinion without figures to back the clain


Anyway, as the developer of phpclasses.org, the largest PHP class repository, I can inform you that the site has accumulated near 270,000 subscriber since 1999, of which at least half of them are considered active as you may verify here:

http://www.phpclasses.org/browse/statistics/statistics.html

The site has 2,200 approved packages but only 71 are PHP 5 specific.

That is a lot of people reusing a lot of public class libraries!

Ah, that thing. The site that always gives me problems when I try to log

I have no idea what problems are talking. All sessions expire after 30 days. If you need to access something that requires authentication, you need to login after 30 days of abscense. If you do not recall your password, you can ask a reminder or to reset the password. Other than that, I don't know problems are you talking about?


in after absence. I had switched to reregistering for every access
before Berlios came along (thanks for threatening to sue them) and now I
use the "Monster TGZs".

I am afraid you are also misunderstanding the matters. That fellow was abusing from the site in several ways. One is that he was ripping all the title and descriptions of the packages that I enter when I approve a class. That is a copyright violation. Another thing is that he was employing robots to leech the site. Not only it was causing excessive load to the server but he was also causing excessive bandwidth usage.

Anyway, I do not care if whoever replicates the package files available in the site. If you want to waste bandwidth on that, that is your problem. I just can't accept serving files to people that act with malice against a site that serves tens of thousands of PHP users, causing me financial expenses that the site advertising revenue can't cover. After all what do you want? Shut down the site so no PHP user can benefit from it?

Anyway, the problem of excessive load and bandwidth, was not being cause by just that fellow. Therefore, in case you do not know, several measures were taken to discourage the use of robots. All the users receiving the site newsletter were told about this. If you have not been in the site lately, once you get there you will realize why leeches will have an hard time to work now. This means that it will be hard to keep up with replication repositories.



--

Regards,
Manuel Lemos

PHP Classes - Free ready to use OOP components written in PHP
http://www.phpclasses.org/

PHP Reviews - Reviews of PHP books and other products
http://www.phpclasses.org/reviews/

Metastorage - Data object relational mapping layer generator
http://www.meta-language.net/metastorage.html

--- End Message ---
--- Begin Message ---

----- Original Message ----- From: "Jasper Bryant-Greene" <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Friday, September 16, 2005 4:45 PM
Subject: Re: [PHP] Quick Poll: PHP 4 / 5


Stephen Leaf wrote:
So yes a bug. But for those that want to be able to grab only what we need. in my case array_pop's returned element. I don't wanna be hassled with the "are you sure you wanted to ignore part of what we did?" It's almost like every program asking "are you sure you wanted to close me?" everytime I get asked that I always think... "I did just click the X.. so.... Yah......."

But why use array_pop() to get the last element, when you know it's intended to shorten its passed array as well?

I mean, sure, it might take a few more lines of code to do it properly, but it has the advantage that whoever has to look at the code next might actually understand what's going on in your head.

$array = explode( ',', $some_string );
$last_element_pos = count( $array ) - 1;
$last_element = $array[$last_element_pos];

[ sure, you could put the count( $array ) - 1 as the array subscript but I was just extending it out for illustration... it's probably easier to understand later on anyway. ]

Actually I choose array_pop for 2 reasons.
I like short code. I don't want to read thousands of lines just to get an idea. I tend to think in very compact code. if you find that ugly and unreadable. that's your preference. I find extended coding very ugly, mostly because I'm a slow reader, and that is my preference I got use to working with pop and shift while I was doing perl work. so to me pop'ing an array makes perfect sense.


--
Jasper Bryant-Greene
Freelance web developer
http://jasper.bryant-greene.name/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



--- End Message ---
--- Begin Message ---
leaf wrote:

Actually I choose array_pop for 2 reasons.
I like short code. I don't want to read thousands of lines just to get an idea. I tend to think in very compact code. if you find that ugly and unreadable. that's your preference. I find extended coding very ugly, mostly because I'm a slow reader, and that is my preference

And what about someone else that has to read/maintain your code in the future? What about when you come to read a "clever" but compact line of code that does 5 or 6 things on a single line, a few years down the track, and spend valuable time just trying to figure out what it actually does?

I got use to working with pop and shift while I was doing perl work. so to me pop'ing an array makes perfect sense.

Sure, when there actually *is* an array to pop. In the following situation there is no array to actually pop (remove and return) the last element from, since you're using the return value of explode() while array_pop() expects a reference to a variable:

$element = array_pop( explode( ',', $some_string ) );

--
Jasper Bryant-Greene
Freelance web developer
http://jasper.bryant-greene.name/

--- End Message ---
--- Begin Message ---
On Sat, 2005-09-17 at 00:14, Jasper Bryant-Greene wrote:
> leaf wrote:
> > 
> > Actually I choose array_pop for 2 reasons.
> > I like short code. I don't want to read thousands of lines just to get 
> > an idea. I tend to think in very compact code. if you find that ugly and 
> > unreadable. that's your preference. I find extended coding very ugly, 
> > mostly because I'm a slow reader, and that is my preference
> 
> And what about someone else that has to read/maintain your code in the 
> future? What about when you come to read a "clever" but compact line of 
> code that does 5 or 6 things on a single line, a few years down the 
> track, and spend valuable time just trying to figure out what it 
> actually does?
> 
> > I got use to working with pop and shift while I was doing perl work. so 
> > to me pop'ing an array makes perfect sense.
> 
> Sure, when there actually *is* an array to pop. In the following 
> situation there is no array to actually pop (remove and return) the last 
> element from, since you're using the return value of explode() while 
> array_pop() expects a reference to a variable:
> 
> $element = array_pop( explode( ',', $some_string ) );

Ahhh but there is an array to pop, returned arrays are still containers
and generally follow the semantics of declared containers (obscure
segfault bugs notwithstanding).

Personally I find:

    $element = array_pop( explode( ',', $some_string ) );

More readable than:

    list( $element ) = explode( ',', $some_string );

But that's because I find assigning to something that looks like a
function disconcerting :)

Maybe what we really need is:

    //
    // First parameter should be a reference and will be altered to
    // reflect the popping of the substring separated by the separator.
    // The second parameter is the separator to use, comma is defaulted
    // but we set it explicitly for readability ;)
    //
    $element = str_pop( $some_string, ',' );

Of course, as soojn as you do that, you know someone will do the
following:

    $element = str_pop( $some_part1.$some_part2, ',' )

Or even worse (teehee):

    $element = str_pop( implode( ',', $some_array ) )

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 ---

----- Original Message ----- From: "Jasper Bryant-Greene" <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Friday, September 16, 2005 11:14 PM
Subject: Re: [PHP] Quick Poll: PHP 4 / 5


leaf wrote:

Actually I choose array_pop for 2 reasons.
I like short code. I don't want to read thousands of lines just to get an idea. I tend to think in very compact code. if you find that ugly and unreadable. that's your preference. I find extended coding very ugly, mostly because I'm a slow reader, and that is my preference

And what about someone else that has to read/maintain your code in the future? What about when you come to read a "clever" but compact line of code that does 5 or 6 things on a single line, a few years down the track, and spend valuable time just trying to figure out what it actually does?
I think in compact code. so reading it back is not a problem. As for future programmers who want to look at my code? That's never happened so far. However I do keep good documentation. so reading and understanding my code shouldn't be a problem.


I got use to working with pop and shift while I was doing perl work. so to me pop'ing an array makes perfect sense.

Sure, when there actually *is* an array to pop. In the following situation there is no array to actually pop (remove and return) the last element from, since you're using the return value of explode() while array_pop() expects a reference to a variable:

$element = array_pop( explode( ',', $some_string ) );
No array to pop? .. explode returns an array. doesn't matter if its temporary or has a variable assigned to it. its still an array.


--
Jasper Bryant-Greene
Freelance web developer
http://jasper.bryant-greene.name/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



--- End Message ---
--- Begin Message ---
Hello,

on 09/15/2005 07:10 AM Oliver Grätz said the following:
NEWSFLASH: PDO already exists for PHP 4:

http://www.phpclasses.org/pdo

One can't implement overloading of the Zend Engine 2 in PHP4 so this is

Who is going to miss that? Anyway, I don't think that is the point of PDO for PHP 4. It is rather that what you do with PDO for PHP 4, it will work with PDO for PHP 5.


not "the full package". And then, the most important feature of PDO is
that it's NOT WRITTEN IN PHP like any other database abstraction layer.
It's written in C for speed.

In theory, that would be a a good advantage. In practice you will hard notice any difference in real world applications because most of the time PHP code will be waiting for the server to execute queries and exchange data.

Furthermore, keep in mind that PHP code is just glue code that already calls native C extensions that take care of the heavy part of database clients, which is marshalling and unmarshalling the data that is exchanged between the client and the server.

This is a big difference between PHP database APIs and for instance JDBC drivers which are mostly written in pure Java code and introduce inefficiencies that PHP APIs do not have because they interface with native client APIs in C provided by the respective database vendors.

Anyway, if you are not convinced and you are obcessed with speed, you may just as well use the native API for accessing the database instead of dealing with PDO overhead and API limitations.


Despite of that, I do not think PDO is a compelling reason to use PHP 5.
Basically it is yet another attempt to do the same where other
abstraction layers extensions have failed like ODBC and DBX.

It will not fail because it will be the de-facto-standard for new
programmers. PHP tutorials will start containing PDO examples instead of
mysql_* examples. That's even more true because the mysql extension is
not included by default anymore.

I think that is purely wishful thinking on your part.

If hosts want to keep their business with PHP clients, they make mysql available to everybody as in PHP 4.



The matter is that PDO does not offer real database independence, so
application developers that want to not have to deal with the important
aspects that are different among databases will still have to deal them
in their applications making their applications non-portable.

This is true for the 10 percent of PHP programmers doing complicated
database stuff. PDO still is good for them because PDO explicitly makes
stuff unique to a particular DBMS available through its interface (the
doc is full of "this will only work for some engines"). The other 90
percent will be fine with what PDO has to offer.

10% doing complicated stuff? Man, you are so biased towards PDO/PHP 5 that you are missing the obvious. I am almost certain that you never tried to do any database indenpendent programming with PDO or whatever that, or else you would not be saying the above.

You see, Wez Furlong, the author of PDO is a well known capable developer, however IMO he made a strategic mistake, probably because he did not consult the PHP database programming community, in copying ODBC as base of PDO API. What happens is that ODBC is a stone-age API that comes from the pre-Web era.

Web programming pushes certain needs that database API must provide somehow, but ODBC did not handle these because they were not so important in the pre-Web era.

Here are just a few examples of non-complicated stuff that 99.9999% of the developers need, for which ODBC/PDO do not provide in an appropriate way:

- Auto-increment field access

- LIMIT (FYI Rasmus Lerdorf, creator of the PHP invented LIMIT)

- Database independent type mapping (actually ODBC provides this but PDO doesn't)

So you understand how do I know this stuff is important for database independent programming, that is because in 1998 I started creating a database independent API for PHP that provides all the above and also several other non-trivial features such as schema management, which AFAIK no other database API provides, not for PHP, nor for any other language.

http://www.phpclasses.org/metabase

When I say above that unfortunately Wez Furlong did not consult the PHP database programming community, I meant that if could have at least checked what the existing PHP database abstraction API like Metabase and others that followed and copied some of its features, instead of departing of a pre-Web API which is ODBC and maybe PDO could have been a much more database independent API, which currently it isn't. This way I am afraid that PDO destiny won't be different from others like PHP ODBC and DBX.


--

Regards,
Manuel Lemos

PHP Classes - Free ready to use OOP components written in PHP
http://www.phpclasses.org/

PHP Reviews - Reviews of PHP books and other products
http://www.phpclasses.org/reviews/

Metastorage - Data object relational mapping layer generator
http://www.meta-language.net/metastorage.html

--- End Message ---
--- Begin Message ---
http://www.iamcal.com/publish/articles/php/parsing_email/

The author goes through RFC822 in detail and writes up a regex that validates emails based on that. It's worked in my experience, but I havn't exactly put it through its paces.

--Rob

bruce wrote:
hi..

looking for a good/working/tested php email validation regex that conforms
to the rfc2822 standard.

a lot of what i've seen from google breaks, or doesn't follow the standard!

any ideas/thoughts/sample code/etc...

thanks

-bruce
[EMAIL PROTECTED]

--- End Message ---
--- Begin Message ---
For anyone unfamillair with Signals and Slots, have a read:
http://doc.trolltech.com/3.3/signalsandslots.html

It certainly cleared things up for me a bit.

I'll comment in a bit, when they're formulated a bit more clearly...

--Rob

Konrad Kleine wrote:
Qt like Signals and Slots (Idea + Implementation)

Hey,

I am a big fan of Qt from Trolltech.com and I especially like the signals and 
slot mechanism. I have implemented a small example in php here.
It is really not thought of to be production ready, but think about it a little 
while ;)

You can emit any signal you want with this example unlike to Qt, where
you have to declarate it in your class.


What is done here?

- There is a base class called "PBase".
- The class "A", "B" and "C" extend the base class "PBase".
- We create objects of all three classes.
- Then we connect a signal sent from the A-object to a slot function in the B- 
and to a completely other slot function in the C-object.
- When calling the method in the A-object that emits this special signals, the 
slot function of the B- and C-object are automatically called in arbitary order.


What needs to be done?

- You must have the ability to disconnect an object from a signal
- The way the connections are saved is bad (I think). It should be sufficient 
to store one reference per object.

Where is the code? Well, here:

<?php

function connect ( $sender_obj, $signal_string, $reciever_obj, $slot_string )
{
        $sender_obj->connect( $sender_obj, $signal_string, $reciever_obj, 
$slot_string );
}

abstract class BaseClass
{
        private $connection_array;
        
        public function __construct()
        {
                $this->connection_array = array();
        }
        
        public function connect( $sender_obj, $signal_string, $reciever_obj, 
$slot_string )
        {
                $tmp                    = array();
                
                $tmp['sender']  = $sender_obj;
                $tmp['signal']  = $signal_string;
                $tmp['reciever']= $reciever_obj;
                $tmp['slot']    = $slot_string;
                
                array_push( $this->connection_array, $tmp );
        }
        
        protected function do_emit_signal()
        {
                $param_count            = func_num_args();
                $param_array            = func_get_args();
                
                if ( $param_count < 1 )
                {
                        trigger_error("the signals name is missing", 
E_USER_NOTICE);
                }
                
                $param_array        = array_slice($param_array, 1, 
$param_count-1, true);
                
                //$sender_name_string = get_class(); // the name of the class 
that has connected
                $signal_name_string     = func_get_arg(0);
                
                foreach ( $this->connection_array as $key => $con )
                {
                        // make sure, we truely talk about the same object 
(@see === operator)
                        if ( $con['sender'] === $this && $con['signal'] == 
$signal_name_string )
                        {
                                call_user_func_array(
                                        array(
                                                $con['reciever'],
                                                $con['slot']
                                        ),
                                        $param_array
                                );
                        }
                }
        }
}

class A extends BaseClass
{
        public function __construct()
        {
      parent::__construct();
        }
        
        public function do_something()
        {
                // do something here...
                // and then you might want to emit a signal
                $this->do_emit_signal("clicked", "it's me from A");
        }
}

class B extends BaseClass
{
        public function __construct()
        {
      parent::__construct();
        }
        public function slot_handle_clicked( $string )
        {
          echo "Hey, I am B and I just caught this value from a signal: <b>" . $string . 
"</b><br />";
        }
}

class C extends BaseClass
{
        public function __construct()
        {
      parent::__construct();
        }
        public function catch_my_signal( $string )
        {
          echo "Hey, I am C and I just caught this value from a signal: <b>" . $string . 
"</b><br />";
        }
}


$obj_a = new A();
$obj_b = new B();
$obj_c = new C();

connect( $obj_a, "clicked", $obj_b, "slot_handle_clicked" );
connect( $obj_a, "clicked", $obj_c, "catch_my_signal" );
$obj_a->do_something();
?>


__________________________________________________________________________
Erweitern Sie FreeMail zu einem noch leistungsstarkeren E-Mail-Postfach!        
        
Mehr Infos unter http://freemail.web.de/home/landingpad/?mc=021131

--- End Message ---
--- Begin Message ---
We need to protect our intellectual property. We wish to encode or obfuscate 
our PHP code before delivering it to a client.

Could someone recommend an free PHP encoder or obfuscating tool. (This is a 
very small project so we can NOT justify buying the Zend encoder. However, 
if there is any other reasonably priced encoder, we might consider that.)

Thank you very much.

-- 
Anas Mughal

--- End Message ---
--- Begin Message ---

----- Original Message ----- From: "Joerg P" <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Friday, September 16, 2005 2:07 PM
Subject: [PHP] xml first special char


hello,

I have some words with german special chars in mysql. When I print those strings direct as xml to the browser, everything seems fine. But there is one 'ä' that makes me crazy. It always appears as a ? in Firefox and even makes an error in ie.

But other 'ä's are ok.....

What could I do?

Joerg
have you tried changing the encoding in firefox to see if it fixes the ?
If that works try enforceing that encoding.
Either with a header(); and/or <?xml encoding=""?>

I use this function to set the header information in most if not all of my websites

You can safely ignore the $this->outXML I use that because I mainly work with XSL documents. appending a ?xml to some of my sites will give you the raw XML perfect for debugging purposes. :)

function outputHeader($docType='', $filename=null) {
 if (!$this->outXML) {
  header("Content-Type: text/html; charset=utf-8");
  echo '<?xml version="1.0" encoding="utf-8" ?>'."\n";
  echo ($docType != '')?
   $docType:
'<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1 //EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd";>'."\n";
 } elseif ($this->outXML) {
  header("Content-Type: text/xml; charset=utf-8");
 } else {
  header("Content-Type: $docType; charset=utf-8");
  if (!empty($filename)) {
   header('Content-Disposition: attachment; filename="'.$filename.'"');
  }
if ($docType=="text/xml") { echo '<?xml version="1.0" encoding="utf-8"?>'."\n"; }
 }
}



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



--- End Message ---
--- Begin Message ---
Can you help me for this problem

Regards,
Nilesh Narkhede



-----Original Message-----
From: Gabor Hojtsy [mailto:[EMAIL PROTECTED] 
Sent: Friday, September 16, 2005 9:34 PM
To: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Subject: Re: PATH_INFO/PATH_TRANSLATED


Hi Nilesh,

Since your problem has nothing to do with
webmastering of the php.net website, it does
not belong in here.... Please contact
[email protected] (a mailing list)
with support questions or see http://php.net/support
for more support options.

Regards,
Gabor Hojtsy

Infoton - Nilesh Narkhede wrote:
> I have problem when i use 
> http://sitename.com/scripts/template.php/new/1. earlier same code was 
> working with another server, but after transfering code to another 
> server. I get error when I access this path 
> http://sitename.com/scripts/template.php/new/1 it gives me error that 
> URL not found.
>  
> I have searched through internet I got answer that problem is with 
> PATH_INFO PATH_TRANSLATED and I need to set cgi.fix_pathinfo=1. I have

> changed the php.ini which is in etc folder. But still the problem is 
> not resolved.
>  
> Can you help me in resolving problem. What settings to be done in 
> server. Am I changing correct ini file I have got this path of ini 
> file using phpinfo().
>  
> Regards,
> Nilesh Narkhede
> 

--- End Message ---

Reply via email to