RE: [PHP] What is the practical use of "abstract" and "interface"?
[snip] ...stuff... [/snip] The practical use of an abstract class is in its ability to define criteria for classes that inherit from it. How practical would it be to define a 'truck' class with 4 wheels and then define a 'car' class with 4 wheels when we could define an abstract class that defines vehicles with 4 wheels? Both of our classes can now inherit from that abstract class and we can define features only relevant to them. If you refactor diligently you will no doubt find places where you need to create abstract classes. The methods that are exposed by an object define the interface for that object. It is how everything outside of the object interacts with the object. You don't have to know how the method works all you need is the interfacelike the gas pedal on the car. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] What is the practical use of "abstract" and "interface"?
Just adding one line to the topic... Interfaces are like C or C++ headers files. Them are used to another class(program in C) to call methods without care the implementation. In other hand abstract classes are (as the name says) an abstract way to use multiple specializations of the same group of classes. Like vehicle is an abstraction to car, motorbike, bike... with that you can use the method ride to all these vehicles using an vehicle variable pointing to an instance of car, motorbike or bike. Cheers. Rodrigo Reis. 2008/4/15, Jay Blanchard <[EMAIL PROTECTED]>: > > [snip] > ...stuff... > [/snip] > > The practical use of an abstract class is in its ability to define > criteria for classes that inherit from it. How practical would it be to > define a 'truck' class with 4 wheels and then define a 'car' class with > 4 wheels when we could define an abstract class that defines vehicles > with 4 wheels? Both of our classes can now inherit from that abstract > class and we can define features only relevant to them. If you refactor > diligently you will no doubt find places where you need to create > abstract classes. > > The methods that are exposed by an object define the interface for that > object. It is how everything outside of the object interacts with the > object. You don't have to know how the method works all you need is the > interfacelike the gas pedal on the car. > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- Atenciosamente, Rodrigo.
[PHP] Most viewed?
Greetings, Can any of you point me in the right direction on how to use PHP to create a most viewed or most clicked articles list? Can it be done with PHP? Thank you so much, Steve Marquez [EMAIL PROTECTED]
Re: [PHP] Most viewed?
On Tue, Apr 15, 2008 at 9:41 AM, Steve Marquez <[EMAIL PROTECTED]> wrote: > Greetings, > > Can any of you point me in the right direction on how to use PHP to create > a > most viewed or most clicked articles list? Can it be done with PHP? are these articles on a site youre creating? it should be pretty simple then. basically, when somebody clicks on a link to an article on the site, drive that request through some php code that increments a counter in the database. then on the page where you show the 'most clicked' its essentially just an ORDER BY most_clicked DESC LIMIT x query. where most_clicked is the field name of the counter, and x is the number of results you want to show; so like for top 3, x=3. -nathan
[PHP] security for hersh site
Hi, I would like to ensure that our php.ini is fully locked down to prevents individuals from any exploiting vulnerabilities in our site. (hershonline.com) What sites do you recommend to gather this information? Do you recommend running tools like securitymetrics.com? I ran this on our site (hersh) and found no real errors. However, I want to make sure that hersh site is fully secure. Thanks for the advice. Thanks, Dale Hersowitz Hersh Corporaton hershonline.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] protecting php from the hersh corporation
Hi, I would like to ensure that our php.ini is fully locked down to prevents individuals from any exploiting vulnerabilities in our site. (hershonline.com) What sites do you recommend to gather this information? Do you recommend running tools like securitymetrics.com? I ran this on our site (hersh) and found no real errors. However, I want to make sure that hersh site is fully secure. Thanks for the advice. Thanks, Dale Hersowitz Hersh Corporaton hershonline.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Most viewed?
Steve Marquez wrote: Greetings, Can any of you point me in the right direction on how to use PHP to create a most viewed or most clicked articles list? Can it be done with PHP? Thank you so much, Steve Marquez [EMAIL PROTECTED] Short answer, yes. The right direction would be something like this: In the article table of your db add a 'reads' field or similar. Modify your article display code so that when it loads it increments the reads field for that article. Now to display the article with the most reads you just query the article table for the max reads or for all articles and sort on reads, etc... -Shawn -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] protecting php from the hersh corporation
Yes, by all means, you will want to protect PHP from your corporation. In fact, we all want you to do the same. No posts in four years, and then - bam! - six posts in one day on three different lists saying the same thing. A little antsy, are we? ;-P -- Ask me about: Dedicated servers starting @ $59.99/mo., VPS starting @ $19.99/mo., and shared hosting starting @ $2.50/mo. Unmanaged, managed, and fully-managed! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Quarters
tedd írta: Hi gang: Check out my new game: http://webbytedd.com/quarters/ What do you think? that's cool, the only problem is that I lost ten times out of ten ;) maybe on the weekend I give it a deeper analysis and so I can figure out the winning strategy - because there must be one, which is used by the program greets, Zoltán Németh Cheers, tedd PS: I originally wrote the game for the Mac over eight years ago. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] where to put a function
Rick Pasotto írta: Probably been answered a thousand times; if so, just tell me where to look. I have a function that includes a specific sql query that is used on only one page on the site. Should that function be coded (1) in the page itself, (2) in a separate file that only that page includes, or (3) in a master file that contains all the functions used on the site and is included on every page? I've been doing #1 (not actually a function in this case) but #3 is appealing, especially since I would implement it as OOP and the page itself would be really just a template. What is the cost of parsing a bunch of functions that are not used on a given page load? Q: where to put a function? A: into the class where it belongs. sorry I could not stand it ;) to be more serious, one giant 'functions.php' include file is not a very good solution, because you might end up including dozens of unused functions in every page. on the other hand, putting it into the page doesn't let you use it anywhere else. so the solution should be somewhat like the oop class organization: put together those that are logically belonging together. this way you'll have libraries for each type of functions, and only include what you need greets, Zoltán Németh -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] getting funny error on working page
I've upgraded my PHP install and now I get this error in my test environment so I'm scared to load any changes up to the production website where this error doesn't exist. What is funny is the page still runs and lists all the data in correct rows, but with an error for each row right at the top of the page. Notice: A non well formed numeric value encountered in C:\Inetpub\wwwroot\mazamaslocal\functions.php on line 15 Oct 02 (Tue) Triple Crown Ken Searl Here is the function * function fMakeWideDate($thisdate,$senderformat) { //parameters: //1 for mm/dd/ date format sent in //2 for /mm/dd date format sent in //this: fWideDate('12/04/2005',1) returns: Dec 04, 2005 (Sun) //this: fWideDAte('2005-12-04',2) returns: Dec 04, 2005 (Sun) if($senderformat==1) //mmdd { $month=substr($thisdate,0,2); $day =substr($thisdate,3,2); $year = substr($thisdate,6,4); $d =date("M d (D)",Mktime(0,0,0,$month,$day,$year)); <<< line 15 errors here (Oct 02 (Tue) ) //echo $d; //$d =date("M d, Y (D)",Mktime(0,0,0,$month,$day,$year)); } elseif($senderformat==2) //mmdd with dashes { $year = substr($thisdate,0,4); $month=substr($thisdate,5,2); $day =substr($thisdate,8,2); $d =date("M d (D)",Mktime(0,0,0,$month,$day,$year)); } return $d; } ** Here is what calls the function basically displaying a userfriendly date //LAY OUT THE ROWS WITH INFO HERE /// $fields=mysql_num_fields($data); {for($i=1 ; $i<=$fields-16; $i++){ if($i==3) //DISPLAY DATE {$WideDate=fMakeWideDate($row[$i],1);echo "".$WideDate.""; }
Re: [PHP] getting funny error on working page
On Tue, Apr 15, 2008 at 5:07 PM, John A DAVIS <[EMAIL PROTECTED]> wrote: [snip!] > > Notice: A non well formed numeric value encountered in > C:\Inetpub\wwwroot\mazamaslocal\functions.php on line 15 > Oct 02 (Tue) Triple Crown Ken Searl It's an E_NOTICE. That means the issue has always existed, it was just never displayed. While you should make every attempt to fix every issue, notices are generally safe to ignore without any serious consequence (keep in mind, I say, "generally"). So you can update your php.ini's error_reporting variable to the following: error_reporting = E_ALL & ~E_NOTICE and then restart IIS (which is what it looks like you're using, based upon path). -- Ask me about: Dedicated servers starting @ $59.99/mo., VPS starting @ $19.99/mo., and shared hosting starting @ $2.50/mo. Unmanaged, managed, and fully-managed! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Quarters
At 8:40 PM +0200 4/15/08, Zoltán Németh wrote: tedd írta: Hi gang: Check out my new game: http://webbytedd.com/quarters/ What do you think? that's cool, the only problem is that I lost ten times out of ten ;) maybe on the weekend I give it a deeper analysis and so I can figure out the winning strategy - because there must be one, which is used by the program greets, Zoltán Németh Zoltán: There's a log story about that game. But briefly, I was introduced to it by an old man in Bradford Penn. I remember it cost me at least a case of beer before I won a single game -- a very deceptive game, at least it was to me. But, the program follows a rule based AI algorithm with a bit of randomness thrown in. I've condensed winning down to three rules -- it will be interesting to see if you can figure out what those rules are. Of course, you could pay $5 and I'll email them to you. :-) Seriously, I released the game for the Mac in December 1999. In February, MacWorld ran it as one of the top ten shareware games and my web site had over 25,000 downloads that month and the 30+ shareware site out that had the game, reported a total of over 200,000 downloads. The original game asked for a self-addressed stamped envelope with $5 in it and I would mail the answer back. To my surprise, I received hundreds of letters and money from all over the world. Some of the currency would have cost me more than $5 to cash at my local bank. That was before PayPal did overseas transactions. Some of the letters had photographs of the people who wanted the secret. I specifically remember a big biker from OZ who sent me a picture of himself and his bike with a note that he was going to make more than $5 by betting on the game in bars. I'm sure he did. It was a very interesting experience and I've always wanted to put the game up on my site to see what would happen. It's not for the money, but rather the life experience. Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Quarters
On Tue, Apr 15, 2008 at 5:17 PM, tedd <[EMAIL PROTECTED]> wrote: > > It was a very interesting experience and I've always wanted to put the game > up on my site to see what would happen. It's not for the money, but rather > the life experience. That being the case, please update the PayPal link to [EMAIL PROTECTED] Thank you for your cooperation. -- Ask me about: Dedicated servers starting @ $59.99/mo., VPS starting @ $19.99/mo., and shared hosting starting @ $2.50/mo. Unmanaged, managed, and fully-managed! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] getting funny error on working page
Thanks! My guess is the production server has this set correctly and I will follow your advice. However, how would one do away with this error? What would I do to guarantee an string being returned instead of a date? What can I wrap the date() function in? $month=substr($thisdate,0,2); $day =substr($thisdate,3,2); $year = substr($thisdate,6,4); $d =date("M d (D)",Mktime(0,0,0,$month,$day,$year)); Again, thank you! John A. Davis >>> "Daniel Brown" <[EMAIL PROTECTED]> 4/15/2008 2:14:16 PM >>> On Tue, Apr 15, 2008 at 5:07 PM, John A DAVIS <[EMAIL PROTECTED]> wrote:[snip!]>> Notice: A non well formed numeric value encountered in> C:\Inetpub\wwwroot\mazamaslocal\functions.php on line 15> Oct 02 (Tue) Triple Crown Ken Searl It's an E_NOTICE. That means the issue has always existed, it wasjust never displayed. While you should make every attempt to fixevery issue, notices are generally safe to ignore without any seriousconsequence (keep in mind, I say, "generally"). So you can updateyour php.ini's error_reporting variable to the following:error_reporting = E_ALL & ~E_NOTICE and then restart IIS (which is what it looks like you'reusing, based upon path).-- Ask me about:Dedicated servers starting @ $59.99/mo., VPS starting @ $19.99/mo.,and shared hosting starting @ $2.50/mo.Unmanaged, managed, and fully-managed!
Re: [PHP] Quarters
Dang it! You beat me to it! Hey Tedd, Make it rotate between [EMAIL PROTECTED] and [EMAIL PROTECTED] :-D Daniel Brown <[EMAIL PROTECTED]> wrote: > On Tue, Apr 15, 2008 at 5:17 PM, tedd <[EMAIL PROTECTED]> wrote: > > > > It was a very interesting experience and I've always wanted to put the game > > up on my site to see what would happen. It's not for the money, but rather > > the life experience. > > That being the case, please update the PayPal link to [EMAIL PROTECTED] > > Thank you for your cooperation. > > -- > > Ask me about: > Dedicated servers starting @ $59.99/mo., VPS starting @ $19.99/mo., > and shared hosting starting @ $2.50/mo. > Unmanaged, managed, and fully-managed! > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] getting funny error on working page
On Tue, Apr 15, 2008 at 5:24 PM, John A DAVIS <[EMAIL PROTECTED]> wrote: > > > Thanks! My guess is the production server has this set correctly and I will > follow your advice. > However, how would one do away with this error? What would I do to guarantee > an string being returned instead of a date? What can I wrap the date() > function in? > >$month=substr($thisdate,0,2); >$day =substr($thisdate,3,2); >$year = substr($thisdate,6,4); > >$d =date("M d (D)",Mktime(0,0,0,$month,$day,$year)); > > > Again, thank you! > John A. Davis I don't think you need to wrap date() in anything, as it should be returning a string. Without seeing the actual input that caused the warning, I think it's probably more an issue with either $month, $day, or $year not being quite right (but close enough that PHP can still obtain the correct result). Is it possible (since you're getting the date from a database query) that the value is coming back as a datetime string that includes a time portion? Your function should work OK if you are getting something that looks like '10-02-2008 10:15:27' but will get the error you reported if it gets the same value as '10022008 10:15:27'. Try doing a var_dump on each value to make sure it's what you expect it to be. Andrew -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Most viewed?
At 10:41 AM -0500 4/15/08, Steve Marquez wrote: Greetings, Can any of you point me in the right direction on how to use PHP to create a most viewed or most clicked articles list? Can it be done with PHP? Thank you so much, Steve Marquez [EMAIL PROTECTED] Steve: There are a couple of ways to do this: 1) use mysql to record each download; 2) use a file to record each download. All you do is pass the user's click to a php script that records the transaction -- incrementing a counter in either mysql or a file and delivers the content to the user. You can include that number in your html to show how many transactions, if you want. This is an example of using a file: http://www.webbytedd.com/b/readwrite-download/ Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Quarters
At 5:43 PM -0400 4/15/08, Wolf wrote: Dang it! You beat me to it! Hey Tedd, Make it rotate between [EMAIL PROTECTED] and [EMAIL PROTECTED] You guys make me laugh. Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP Speech
Daniel: Your hosting service provides the capability to turn html text to speech, as I've done here: http://php1.net/b/speech/ We use php to generate a sound file and then we use javascript to play it -- it all works great. But, how do we delete the file? The php script is history after presenting the page and javascript can't touch the server, right? So, how does one delete the wave file? The only way I can see is to set up a cron job to delete all wave files after a certain time, but that's kind-of lame. Is there another way? Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Forking and fsock
Is there a way I can get my fsock to stay open when the child process exits? Kyle -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Forking and fsock
You're trying to save an open socket connection that was gained by the fork()'d process? I don't think that would be possible, since PHP closes all the resources when the process ends. Unless there is some config option to not do that. Jason On Tue, Apr 15, 2008 at 4:16 PM, Kyle Browning <[EMAIL PROTECTED]> wrote: > Is there a way I can get my fsock to stay open when the child process > exits? > > Kyle > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > >
[PHP] PHP with NNTP?
Hi, Can anybody tell me how can php connect to NNTP to get the list of all users in the newsgroups? thanks, -- View this message in context: http://www.nabble.com/PHP-with-NNTP--tp16713817p16713817.html Sent from the PHP - General mailing list archive at Nabble.com. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP Speech
On Tue, Apr 15, 2008 at 7:04 PM, tedd <[EMAIL PROTECTED]> wrote: > > Your hosting service provides the capability to turn html text to speech, > as I've done here: [snip!] > > But, how do we delete the file? The php script is history after presenting > the page and javascript can't touch the server, right? So, how does one > delete the wave file? > > The only way I can see is to set up a cron job to delete all wave files > after a certain time, but that's kind-of lame. Is there another way? Right, but unfortunately, because it's audio that needs to stream, it can't just be served like an image (think GD or imagemagick) and then destroyed. There is no way to know how long it will be before the client receives the entire file, and it would prove to be too much to store in a reasonable buffer. That's why I had to write it the way it is. The drawback is that, yes, unless you're overwriting the file each time (which, with high-traffic sites, would corrupt larger files mid-download), you either have to have a script to unlink() the files or a cron to remove them (or resort to a manual removal). I'm all ears, eyes, and cerebellum if you've got an idea on how to fix that though. The next phase should have better speech, I'm just having a tough time with paid gigs now and find no time to focus on the fun stuff really. I still don't know why no one ever told us the truth that, no matter how much we wanted to be Toys 'R' Us kids, the answer was unscrupulously the same: tough nuts. -- Ask me about: Dedicated servers starting @ $59.99/mo., VPS starting @ $19.99/mo., and shared hosting starting @ $2.50/mo. Unmanaged, managed, and fully-managed! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] getting funny error on working page
On Tue, Apr 15, 2008 at 5:24 PM, John A DAVIS <[EMAIL PROTECTED]> wrote: > > > Thanks! My guess is the production server has this set correctly and I will > follow your advice. > However, how would one do away with this error? What would I do to guarantee > an string being returned instead of a date? What can I wrap the date() > function in? > > >$month=substr($thisdate,0,2); >$day =substr($thisdate,3,2); >$year = substr($thisdate,6,4); > >$d =date("M d (D)",Mktime(0,0,0,$month,$day,$year)); Sorry, my Xorg crashed. A word of wisdom: don't try the new Compiz-Fusion on KDE with dual-headed setups yet. Let the bugs get worked out first (or risk having a conspicuous hole in the wall the size of your forehead like I will in a few days). To your issue: * What are you passing to parameter #1 of fMakeWideDate() (then dubbed $thisdate)? * Mktime() should be mktime(). It'll still work, but for cleanliness, it's a recommendation. When I run the function like so, it works without fail: Are you correctly passing the date? What do you see when you echo out the MySQL rows? -- Ask me about: Dedicated servers starting @ $59.99/mo., VPS starting @ $19.99/mo., and shared hosting starting @ $2.50/mo. Unmanaged, managed, and fully-managed! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] What is the practical use of "abstract" and "interface"?
On Tuesday 15 April 2008, Daevid Vincent wrote: > I've had at least three job interviews in the past two weeks, and each one > has asked me this rather "text book academic" question regarding the > difference between "abstract" vs. "interface". I've been coding for nearly > 20 years, and at least 10 of those have been in PHP and another 3 in J++. I > have NEVER used either of these concepts/keywords? Am I missing some > exciting tool/feature? > > All the reading I've done tonight just reinforces my thoughts that these > are, for the most part useless. Unless you're building some HUGE project > that has an API and there are teams of people that are going to extend your > framework, then what good are they? You've just answered your own question, albeit in a rather naive way. If your code doesn't have an API and clear separation of parts, then neither abstract classes nor interfaces are useful to you. If you're coding anything of respectable size, vis, more than a one-off 1000 line script or less, then you either want to have an API and clear separation of parts or I don't want to hire you, because your code is going to be an unmaintainable mess. Abstract classes and interfaces are a standardized, syntactic way to establish an API and clean separation of parts. They are not the only way to accomplish that goal by any means, but they are a commonly understood way that, if used properly, can create a very good API and very clean separation of parts. If used stupidly, of course, you'll create a system that is completely inflexible and impossible to extend. That comes down to the skill and experience of the developer and architect. If you're not writing OOP code, then neither is of any use to you as both are OOP concepts. (And you don't have to write OOP code if it doesn't make sense, but don't shun it either because often it does make sense.) In general, an interface defines a "front end" of a class, without specifying anything about its implementation. All component A needs to know about component B is that it implements interface Foo, meaning that you know, absolutely, that you can call $b->foo() and get back a string and $b->bar() and get back a database connection, because the interface says so. (If that's not the case, then B is buggy by definition.) You don't know or care how it goes about getting that database connection (creates it, loads it from a cache, creates a fake one for you, etc.), just that you can call $b->bar() and get back a database connection. A class may implement any number of interfaces. An abstract class defines a "front end" *and* the implementation behind it, modulo some bits. It is exactly the same as any other parent class, except that it defines bits of functionality that it is missing that its child classes *must* finish. That's useful if you have some number of classes that are *almost* the same, but have no "generic" form. Database abstraction systems are probably the canonical example here. Usually, you will want to use an interface (possibly with composition) over an abstract class unless you have a ton of shared code, as interfaces are more flexible in a single-inheritance system. Yes, you can get by just fine without them. You can also get by without OOP at all. However, there are some problems where OOP just makes things a lot easier, and in OOP there are places where having a formal interface just makes things a lot easier; like, say, when you're reading someone else's code and trying to make sense of what it's supposed to do and what assumptions are being made. Having that built right into the syntax can be quite useful, even in a loosely typed language like PHP. -- 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 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] What is the practical use of "abstract" and "interface"?
ALarry Garfield wrote: On Tuesday 15 April 2008, Daevid Vincent wrote: I've had at least three job interviews in the past two weeks, and each one has asked me this rather "text book academic" question regarding the difference between "abstract" vs. "interface". I've been coding for nearly 20 years, and at least 10 of those have been in PHP and another 3 in J++. I have NEVER used either of these concepts/keywords? Am I missing some exciting tool/feature? All the reading I've done tonight just reinforces my thoughts that these are, for the most part useless. Unless you're building some HUGE project that has an API and there are teams of people that are going to extend your framework, then what good are they? You've just answered your own question, albeit in a rather naive way. If your code doesn't have an API and clear separation of parts, then neither abstract classes nor interfaces are useful to you. If you're coding anything of respectable size, vis, more than a one-off 1000 line script or less, then you either want to have an API and clear separation of parts or I don't want to hire you, because your code is going to be an unmaintainable mess. Abstract classes and interfaces are a standardized, syntactic way to establish an API and clean separation of parts. They are not the only way to accomplish that goal by any means, but they are a commonly understood way that, if used properly, can create a very good API and very clean separation of parts. If used stupidly, of course, you'll create a system that is completely inflexible and impossible to extend. That comes down to the skill and experience of the developer and architect. If you're not writing OOP code, then neither is of any use to you as both are OOP concepts. (And you don't have to write OOP code if it doesn't make sense, but don't shun it either because often it does make sense.) In general, an interface defines a "front end" of a class, without specifying anything about its implementation. All component A needs to know about component B is that it implements interface Foo, meaning that you know, absolutely, that you can call $b->foo() and get back a string and $b->bar() and get back a database connection, because the interface says so. (If that's not the case, then B is buggy by definition.) You don't know or care how it goes about getting that database connection (creates it, loads it from a cache, creates a fake one for you, etc.), just that you can call $b->bar() and get back a database connection. A class may implement any number of interfaces. An abstract class defines a "front end" *and* the implementation behind it, modulo some bits. It is exactly the same as any other parent class, except that it defines bits of functionality that it is missing that its child classes *must* finish. That's useful if you have some number of classes that are *almost* the same, but have no "generic" form. Database abstraction systems are probably the canonical example here. Usually, you will want to use an interface (possibly with composition) over an abstract class unless you have a ton of shared code, as interfaces are more flexible in a single-inheritance system. Yes, you can get by just fine without them. You can also get by without OOP at all. However, there are some problems where OOP just makes things a lot easier, and in OOP there are places where having a formal interface just makes things a lot easier; like, say, when you're reading someone else's code and trying to make sense of what it's supposed to do and what assumptions are being made. Having that built right into the syntax can be quite useful, even in a loosely typed language like PHP. And, I believe that you can't instantiate abstract classes, they can only be inherited. -Shawn -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] What is the practical use of "abstract" and "interface"?
> -Original Message- > From: Larry Garfield [mailto:[EMAIL PROTECTED] > > If your code doesn't have an API and clear separation of > parts, then neither > abstract classes nor interfaces are useful to you. > > If you're coding anything of respectable size, vis, more than > a one-off 1000 > line script or less, then you either want to have an API and > clear separation > of parts or I don't want to hire you, because your code is > going to be an unmaintainable mess. That is s not true. My last company had nearly 15 developers and we never used either of these concepts in the six years the company existed. We had perhaps 50+ classes and some had upwards of 5-KLOC each. We had three databases with almost 300 tables. We had an external XML API that hooked into these classes with 'set', 'get', 'add', 'delete' and all the commands you would expect. And we weren't doing simple stuff either. This was an extremely complex appliance that was HEAVILY PHP/Ruby driven (http://www.lockdownnetworks.com). I'm not trying to start a war here, I just really don't see how any PHP project other than the very fringe examples such as a DB abstraction project or huge PEAR project has any _real_ need for this. Sure, it's all text-book and "proper" perhaps, but to me it just seems like bloat and if you intend to extend a given class, you STILL have to read the source code and examine the abstract class or interface anyways to know what you have to implement in your derived class (right?) 90% of the LAMP projects amount to some website/service, some user registration, some blogs or threaded discussion, some database entries. They're really not all that complex in the big picture. I can sort of see the use for these if you were designing an operating system or a device driver or something HUGE. But come on -- a website is really not that big (code wise). It may have thousands of pages, but they're built from a relatively small amount of dynamic PHP pages. In any event, thanks for your detailed reply Larry. I get the concepts. I just don't see the general-use-case need in PHP's OOP world. Maybe sometime the light-switch will flip on for me and I'll realize I've been skating uphill all these years... Daevid. P.S. you should look at my resume before you decide not to hire me ;-p http://resume.daevid.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP with NNTP?
vester_s wrote: > > Hi, > > Can anybody tell me how can php connect to NNTP to get the list of all > users in the newsgroups? > I'm not sure about getting "all the users", but you could create a connection using plain socket programming. NNTP is a pretty simple protocol. /Per Jessen, Zürich -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP with NNTP?
vester_s wrote: Hi, Can anybody tell me how can php connect to NNTP to get the list of all users in the newsgroups? http://php.net/imap supports nntp. -- Postgresql & php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php