php-general Digest 12 Oct 2007 17:10:14 -0000 Issue 5069
php-general Digest 12 Oct 2007 17:10:14 - Issue 5069 Topics (messages 263131 through 263156): Re: preg_match_all Help 263131 by: Jim Lucas 263135 by: admin.buskirkgraphics.com 263140 by: Richard Heyes 263141 by: Al Compose MP3 from a php enabled flash page. 263132 by: John Taylor-Johnston 263156 by: Tom Ray [Lists] Re: Classes - Dumb question 263133 by: Larry Garfield 263134 by: Nathan Nobbe 263142 by: tedd 263143 by: Stut 263146 by: Jay Blanchard 263148 by: Nathan Nobbe 263152 by: Jay Blanchard Re: Generating PDF files (XSLT, ps, XSL-FO, FOP, etc) 263136 by: Per Jessen Re: Need help adding dBase support to PHP 263137 by: Jon Westcot 263138 by: Nathan Nobbe 263139 by: Jon Westcot Re: Filter input 263144 by: tedd Re: How to decode the PHP Source Code 263145 by: tedd 263147 by: David Giragosian 263153 by: Daniel Brown Re: round() 263149 by: tedd 263150 by: tedd 263151 by: tedd 263154 by: Nathan Nobbe Re: Something you can do with AJAX + PHP as well 263155 by: tedd 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] -- ---BeginMessage--- [EMAIL PROTECTED] wrote: I have tried this many way and for some reason I cannot pull content between the 2 pattern options. function pullchannel($document) { preg_match_all('/div class=channel [^]*(.*)div class=channel [^]*/i',$document,$elements); $match = implode(\r\n,$elements[0]); $match = str_replace('',,$match); return $match; } Give us and example of the input data. And tell us from that example, what it is you are expecting to extract from it. Jim ---End Message--- ---BeginMessage--- Okay use this as an example I want put parse the html document and toss everything between the two Div class channels into an array. The problem I am having is that I cannot grab everything in between the Pattern of the preg_match_all. If I preg_match_all('/div class=channel [^]*/i',$document,$elements); it works perfection But only arrays the single div statement not everything from div to div. I think somewhere the syntax of the preg_match_all or the implode that is not allow this function to work. Html document div class=channel id=one div class=title bStation Manager/b div class=topicBecause you Can! /div /div /div div class=channel id=two Php script function pullchannel($document) { preg_match_all('/div class=channel [^]*(.*)div class=channel [^]*/i',$document,$elements); $match = implode(\r\n,$elements[0]); $match = str_replace('',,$match); return $match; } -Original Message- From: Jim Lucas [mailto:[EMAIL PROTECTED] Sent: Thursday, October 11, 2007 9:41 PM To: [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Subject: Re: [PHP] preg_match_all Help [EMAIL PROTECTED] wrote: I have tried this many way and for some reason I cannot pull content between the 2 pattern options. function pullchannel($document) { preg_match_all('/div class=channel [^]*(.*)div class=channel [^]*/i',$document,$elements); $match = implode(\r\n,$elements[0]); $match = str_replace('',,$match); return $match; } Give us and example of the input data. And tell us from that example, what it is you are expecting to extract from it. Jim -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php ---End Message--- ---BeginMessage--- [EMAIL PROTECTED] wrote: ... It would help to see the input text and to know exactly what you're trying to match. -- Richard Heyes +44 (0)800 0213 172 http://www.websupportsolutions.co.uk Knowledge Base and HelpDesk software that can cut the cost of online support ---End Message--- ---BeginMessage--- Assuming you know all the permissible div tag classes you want to capture the contents of I'd make an array list of them and the use a foreach() loop and capture the contents you want and not try to capture the contents between the channel divs. Assemble the output array inside the loop. You can also easily keep track of which channel ID the contents came from. What you are attempting directly with preg_match_all() is possible; but, the required pattern is very messy and will be hard to test to make certain it's perfect. [EMAIL PROTECTED] wrote: Okay use this as an example I want put parse the html document and toss everything between the two Div class channels into an array. The problem I am having is that I cannot grab everything in between the Pattern of the preg_match_all. If I preg_match_all('/div
Re: [PHP] Classes - Dumb question
On 10/12/07, Larry Garfield [EMAIL PROTECTED] wrote: On Thursday 11 October 2007, Jay Blanchard wrote: [snip] okay, this is really (!) embarassing, but I have to ask: Why would I want to use classes in PHP? I have been using PHP for years now and writing the normal functions all the time. I have never even bothered working with classes, but now I would love to know what makes the classes so special... Please go easy on me ;o) Just trying to make another step :o) [/snip] Do not be embarrassed, this is a very good question. First of all what you call normal is procedural or functional programming. There is nothing wrong with doing things this way and may be especially quick and efficient when doing basic web sites and applications. Document well and you will have no problem maintaining your code. One correction. What is being described is procedural or imperative programming. Functional programming is another beast entirely (closures, first-class functions, immutable variables, etc.). PHP is not a functional language by any stretch of the imagination. For functional programming, see Erlang, Haskel, ML, LISP, and to a lesser extent Javascript. That's not a knock against PHP, mind you; I'm just pointing out that functional programming is something different than what you are describing. It's a common point of confusion because in a procedural language (traditional PHP, C, etc.) you do everything with functions, so it's functional. The difference is that a function is not a base data type, which is a key component of a functional language. an aspect that makes working with javascript rather interesting. i get my fill of it there and enjoy php for what it is; and because its more familiar to me ;) -nathan
RE: [PHP] preg_match_all Help
Okay use this as an example I want put parse the html document and toss everything between the two Div class channels into an array. The problem I am having is that I cannot grab everything in between the Pattern of the preg_match_all. If I preg_match_all('/div class=channel [^]*/i',$document,$elements); it works perfection But only arrays the single div statement not everything from div to div. I think somewhere the syntax of the preg_match_all or the implode that is not allow this function to work. Html document div class=channel id=one div class=title bStation Manager/b div class=topicBecause you Can! /div /div /div div class=channel id=two Php script function pullchannel($document) { preg_match_all('/div class=channel [^]*(.*)div class=channel [^]*/i',$document,$elements); $match = implode(\r\n,$elements[0]); $match = str_replace('',,$match); return $match; } -Original Message- From: Jim Lucas [mailto:[EMAIL PROTECTED] Sent: Thursday, October 11, 2007 9:41 PM To: [EMAIL PROTECTED] Cc: php-general@lists.php.net Subject: Re: [PHP] preg_match_all Help [EMAIL PROTECTED] wrote: I have tried this many way and for some reason I cannot pull content between the 2 pattern options. function pullchannel($document) { preg_match_all('/div class=channel [^]*(.*)div class=channel [^]*/i',$document,$elements); $match = implode(\r\n,$elements[0]); $match = str_replace('',,$match); return $match; } Give us and example of the input data. And tell us from that example, what it is you are expecting to extract from it. Jim -- 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] Re: Generating PDF files (XSLT, ps, XSL-FO, FOP, etc)
Colin Guthrie wrote: If found a really good quote the other day about XSL but I now can't find the link and it's gone from my history but it was something like: You could write a insert obscure lanaguage here parser/lexer in XSLT but I'm not going to. It's a very powerful language but the hardest part most extreme advocates find is knowing when there is a better/more practical tool for the job ;) There's something incredibly elegant about XML+XSLT - which makes it important to know when NOT to use it ... you're sometimes tempted to massage your data into XML just to be able to XSLT on it. OTOH, when your data is hierarchical/recursive in nature, XSLT is brilliant! /Per Jessen, Zürich -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Need help adding dBase support to PHP
Hi Nathan: The page you referenced in the PHP documentation is exactly what I saw that indicated that the dBase functions needed to be compiled in with the --enable-dbase directive. What I need to know is HOW to do this, even in general terms. GoDaddy is being very little help (no big surprise there). Their last message indicated updating values in the php.ini file would let this work, but, as you pointed out, this isn't an option with the php.ini. I looked in the phpinfo data and couldn't find anything that matched dbase anywhere; certainly, no section in the output indicated any dBase settings whatsoever. I'm fearing that I'm going to have to find some other way to handle the extraction of data from DBF files if I can't get this to work. Thanks again for your help. Jon - Original Message - From: Nathan Nobbe To: Jon Westcot Cc: PHP General Sent: Thursday, October 11, 2007 6:06 PM Subject: Re: [PHP] Need help adding dBase support to PHP On 10/11/07, Jon Westcot [EMAIL PROTECTED] wrote: Hi again: Thanks for the info. From what I can see, GoDaddy does NOT provide access to ssh. Any other thoughts? Or is there some way to tell me, in general terms, how to configure PHP to allow the dbase functions to be used? if godaddy is recommending that you place values in a .htaccess file they probly mean you should upload a .htaccess file via ftp. im assuming thats how the give you access to the system (since there is no ssh access). im a bit unsure of the .htaccess setting, though i recently posted a small how-to on using .htaccess files to override settings in php.ini; this is common in shared hosting environments. http://gentoo-wiki.com/HOWTO_php.ini_overrides_w/_.htaccess basically, to have dbase support, php must be compiled w/ --enable-dbase, per the documentation. http://www.php.net/manual/en/rlef.dbase.php perhaps, it is compiled in and the php.ini settings are preventing you from using the functions (though that sounds hard to believe). you might try tossing a phpinfo script on the box and looking for dbase in the output; particularly look for --enable-dbase, or --disable-dbase. you should see a dbase section also, if its compiled in. if it is there we can get a better idea of what sort of values could be placed in the .htaccess file that would influence the behavior of the dbase component on that system. -nathan
Re: [PHP] Need help adding dBase support to PHP
On 10/12/07, Jon Westcot [EMAIL PROTECTED] wrote: Hi Nathan: The page you referenced in the PHP documentation is exactly what I saw that indicated that the dBase functions needed to be compiled in with the --enable-dbase directive. What I need to know is HOW to do this, even in general terms. basically you run about 3 commands. configure make make install and configure is the command you would pass --enable-dbase to. windows systems typically have binary installs available; but i really have never setup php on a windows box. anyway, the reason i asked about the distribution to begin with is many distributions handle php configuration / installation so its quite simple. on gentoo you just add or remove a use flag and emerge it again if you want to make a change. on debian there are modules so i believe you can just apt-get a new module if it isnt already installed. seems nice, but ill tell you, on gentoo you spend time compiling; on debian you spend time saying where is that package i want and how do i trick apt-get to install it correctly. but i digress... :) GoDaddy is being very little help (no big surprise there). Their last message indicated updating values in the php.ini file would let this work, but, as you pointed out, this isn't an option with the php.ini. I looked in the phpinfo data and couldn't find anything that matched dbase anywhere; certainly, no section in the output indicated any dBase settings whatsoever. if you havent done so i would just use the search feature of your browser and type in dbase on that page. you should see something in the configure directive; either --enable-dbase or --disable-dbase most likely. I'm fearing that I'm going to have to find some other way to handle the extraction of data from DBF files if I can't get this to work. are you really committed to godaddy at this point ? -nathan
Re: [PHP] Need help adding dBase support to PHP
Hi Nathan: Thanks for the info. Unfortunately, it's not my call which host to use. I'm just being asked to help write some code, and I know that there are DBFs in the process that need to be examined and brought into MySQL on a daily basis, if not more often. From what I've been told, the GoDaddy server is a shared server, which I guess means that we, the underlings using it, can't really get in and make whatever changes we'd like to make. I did use the browser search to look for any occurence of dbase in the phpinfo-returned data, but nothing showed up. I appreciate the help you've given. I'll just have to wait and see if the person who owns the site is able to get anywhere with the GoDaddy tech support. Thanks again, Jon - Original Message - From: Nathan Nobbe [EMAIL PROTECTED] To: Jon Westcot [EMAIL PROTECTED] Cc: PHP General php-general@lists.php.net Sent: Friday, October 12, 2007 12:27 AM Subject: Re: [PHP] Need help adding dBase support to PHP On 10/12/07, Jon Westcot [EMAIL PROTECTED] wrote: Hi Nathan: The page you referenced in the PHP documentation is exactly what I saw that indicated that the dBase functions needed to be compiled in with the --enable-dbase directive. What I need to know is HOW to do this, even in general terms. basically you run about 3 commands. configure make make install and configure is the command you would pass --enable-dbase to. windows systems typically have binary installs available; but i really have never setup php on a windows box. anyway, the reason i asked about the distribution to begin with is many distributions handle php configuration / installation so its quite simple. on gentoo you just add or remove a use flag and emerge it again if you want to make a change. on debian there are modules so i believe you can just apt-get a new module if it isnt already installed. seems nice, but ill tell you, on gentoo you spend time compiling; on debian you spend time saying where is that package i want and how do i trick apt-get to install it correctly. but i digress... :) GoDaddy is being very little help (no big surprise there). Their last message indicated updating values in the php.ini file would let this work, but, as you pointed out, this isn't an option with the php.ini. I looked in the phpinfo data and couldn't find anything that matched dbase anywhere; certainly, no section in the output indicated any dBase settings whatsoever. if you havent done so i would just use the search feature of your browser and type in dbase on that page. you should see something in the configure directive; either --enable-dbase or --disable-dbase most likely. I'm fearing that I'm going to have to find some other way to handle the extraction of data from DBF files if I can't get this to work. are you really committed to godaddy at this point ? -nathan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] preg_match_all Help
Assuming you know all the permissible div tag classes you want to capture the contents of I'd make an array list of them and the use a foreach() loop and capture the contents you want and not try to capture the contents between the channel divs. Assemble the output array inside the loop. You can also easily keep track of which channel ID the contents came from. What you are attempting directly with preg_match_all() is possible; but, the required pattern is very messy and will be hard to test to make certain it's perfect. [EMAIL PROTECTED] wrote: Okay use this as an example I want put parse the html document and toss everything between the two Div class channels into an array. The problem I am having is that I cannot grab everything in between the Pattern of the preg_match_all. If I preg_match_all('/div class=channel [^]*/i',$document,$elements); it works perfection But only arrays the single div statement not everything from div to div. I think somewhere the syntax of the preg_match_all or the implode that is not allow this function to work. Html document div class=channel id=one div class=title bStation Manager/b div class=topicBecause you Can! /div /div /div div class=channel id=two Php script function pullchannel($document) { preg_match_all('/div class=channel [^]*(.*)div class=channel [^]*/i',$document,$elements); $match = implode(\r\n,$elements[0]); $match = str_replace('',,$match); return $match; } -Original Message- From: Jim Lucas [mailto:[EMAIL PROTECTED] Sent: Thursday, October 11, 2007 9:41 PM To: [EMAIL PROTECTED] Cc: php-general@lists.php.net Subject: Re: [PHP] preg_match_all Help [EMAIL PROTECTED] wrote: I have tried this many way and for some reason I cannot pull content between the 2 pattern options. function pullchannel($document) { preg_match_all('/div class=channel [^]*(.*)div class=channel [^]*/i',$document,$elements); $match = implode(\r\n,$elements[0]); $match = str_replace('',,$match); return $match; } Give us and example of the input data. And tell us from that example, what it is you are expecting to extract from it. Jim -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Something you can do with AJAX + PHP as well
At 5:02 PM +0200 10/11/07, Per Jessen wrote: tedd wrote: For example: If you have a process that is taking time server-side and want to let the user know in real time what the progress is, this is one way to do it. That's not something (by definition) you can do with javascript alone, right? Correct, but it doesn't require any ajax either. That was my main point. Yes, but I didn't say that my demo *required* ajax either -- so, I don't know why you want to make a point about something not claimed? Here's my demo: http://webbytedd.com/b/timed-php/ Where does it say that Ajax is required?! The demo is self explanatory as to what it is showing. I simply created the demo and presented it here for review. But for some, instead of understanding what the demo was doing, made statements that it was an overkill that could be done more simply by using javascript alone, which was absolutely not true and clearly demonstrated that they didn't understand the demo (my bad for not making it more clear). If you have something constructive to say in relation to the demo, please do. But, I think it's misleading and confusing to point out something that was not claimed and then object to it. Why do that? That's just being argumentative for no reason. I'll tell you what, why don't you create a demo to exhibit whatever points you want to make? I am sure that my comments will be more germane. 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] Compose MP3 from a php enabled flash page.
John Taylor-Johnston wrote: I have an educational web site. I want to create an interface where my students can record their voices client side and then save messages server side. I thought Odeo would solve my problems. (The have their own problems now.) Then I tried: MyChingo and Mobasoft. COme on $6,000 for a site licence. Are there any php alternatives? Or do you know an flash code I can find in sourceforge, that I might hack, or combine PHP Flash so they can record me messages in mp3 and submit them? John John- I guess my question is do you really need Flash for this? If they are uploading their recorded messages client side then they should be able to record/convert the audio files to .MP3 before even uploading them. If you just need the files somewhere online where you can download them for playback later (or even stream from the site) then really all you need is an Upload script that will take their audio files and upload them to the server to a specific location. Now if you want to offer a conversion of WAV to MP3 for them, I suggest FFMpeg, it's run on the server side. You can modify your upload script to not only upload the WAV file but then convert it out to MP3 to a specific location using FFMPeg commands then trash the WAV file. Do you have control over the server or are you just hosting your website there? You'll need to find out if the upload function is even turned on and what the max file size for upload is. Otherwise you'll just have to make a few minor adjustments to your php.ini to handle the larger file uploads. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: RE: [PHP] round()
tedd wrote: At 7:30 PM -0700 10/11/07, Instruct ICC wrote: Now I see why BCMath was mentioned. Yes, but precision is not the issue. It doesn't make any difference if you are rounding. (a) 1.489123451985765 or (b) 148912345198576.5 You still have to make a decision as to if the above (a) rounds to: (a) 1.48912345198577 or (a) 1.48912345198576 or the above (b) rounds to: (b)148912345198577 or (b) 148912345198576 It's a question of rounding, not precision. 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 It's a question of what you expect from a rounding function. If you work with reals on a computer you always have a bit of fuzzynes due to the internal conversions from float to binary and resulting truncations. If you need reproducable results which fit your expectations and if speed doesn't matter just use your own routine depending on string comparison. YMMV -- View this message in context: http://www.nabble.com/round%28%29-tf4602528.html#a13177072 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
[PHP] Re: Screenshot from web page
Check the Imagick php-extension API for the Imagemagick commands. I recall there is a an html= jpg or any image format. Gevorg Harutyunyan wrote: Hi, I would like to make web page screenshot and generate an image for example .jpg or .png using PHP,Apache. If any one has experiance in doing that please help. I know that there are lot of services like that, but I don't want to use them. In real I need that to generate screenshot of my local server pages. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Screenshot from web page
Hi, I would like to make web page screenshot and generate an image for example .jpg or .png using PHP,Apache. If any one has experiance in doing that please help. I know that there are lot of services like that, but I don't want to use them. In real I need that to generate screenshot of my local server pages. -- Best Regards, Gevorg Harutyunyan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How to decode the PHP Source Code
On 10/12/07, David Giragosian [EMAIL PROTECTED] wrote: On 10/12/07, tedd [EMAIL PROTECTED] wrote: At 9:57 AM -0400 10/11/07, Daniel Brown wrote: By the way, Tedd you alright there? Ya' kinda' got squashed. -- Daniel P. Brown I'm find, but I lost my thought -- it's happening more these days. :-) Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com I found a thought when I was drifting off to sleep last night. Maybe it was yours, tedd. But it was in a foreign language - looked like perl. Couldn't make heads or tails of it. David Last night I had a dream of a black and white sitcom about a couple in the pioneering days of the commercial Internet. It was called I Dream of GEnie. -- Daniel P. Brown [office] (570-) 587-7080 Ext. 272 [mobile] (570-) 766-8107 Give a man a fish, he'll eat for a day. Then you'll find out he was allergic and is hospitalized. See? No good deed goes unpunished -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] RE: round()
At 7:30 PM -0700 10/11/07, Instruct ICC wrote: Now I see why BCMath was mentioned. Yes, but precision is not the issue. It doesn't make any difference if you are rounding. (a) 1.489123451985765 or (b) 148912345198576.5 You still have to make a decision as to if the above (a) rounds to: (a) 1.48912345198577 or (a) 1.48912345198576 or the above (b) rounds to: (b)148912345198577 or (b) 148912345198576 It's a question of rounding, not precision. 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] round()
At 10:22 AM -0400 10/11/07, Nathan Nobbe wrote: On 10/11/07, tedd mailto:[EMAIL PROTECTED][EMAIL PROTECTED] wrote: At 4:18 PM -0600 10/10/07, mailto:[EMAIL PROTECTED][EMAIL PROTECTED] wrote: I disagree. I will need to see an example where the round() is inaccurate. You may disagree if you wish, but the php function round() is inaccurate by definition -- all *rounding* algorithms are inaccurate. thats why i suggested the bcmath based algorithm, as bcmath supports arbitrary precision. i built a quick test script using the method from the top comment of the bcmath page, and round(). it allows for quick comparisons of the 2 algorithms and tells you if the results are the same. i messed around w/ it a little bit and the results were the same every time. Well, if the results were the same, then both exhibit the same accuracy bias in rounding. However, precision is not the issue. There's a difference between precision and accuracy and I am addressing accuracy. For example, if the answer is 4.5, then 4.4 is more accurate than 4.399, but the later is more precise. 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] Classes - Dumb question
tedd wrote: function customer($whatWas, $customertype, $whatAdditional) { /* do what was (i.e., common to all) */ /* then do what's additional unique to type */ switch(1) { case $customertype =='Commercial': commercialCustomer($whatAdditional); break; .. and so on } function commercialCustomer($whatAdditional) { /* *only code unique to commercial customers */ } function militaryCustomer($whatAdditional) { /* *only code unique to military customers */ } In either case, I still have to write more code to accommodate scaling. And, if I have more customer types, then it's a simple matter to add more customer functions and addition case statements to the initial customer function. I don't see the benefit in using a class. At this point, it just looks like a different way of doing things. You can limit the need to add more code like so... function customer($whatWas, $customertype, $whatAdditional) { /* do what was (i.e., common to all) */ /* then do what's additional unique to type */ $func = strtolower($customertype).'Customer'; $func($whatAdditional); } You could do (and I have done) something similar with classes. For me the biggest benefit of using OOP is __autoload(). It makes life so much easier. -Stut -- http://stut.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Classes - Dumb question
On 10/12/07, Jay Blanchard [EMAIL PROTECTED] wrote: No doubt. (are you by chance continuing the other argument, re: interfaces?), but you have to break open the original tested function, add code to it, test it, etc. Every time you add a new case you have to break open the existing function to add that case. After a while, say if you need to drop a customer type you would have to (not really, you can leave it there and never exercise the case) break open the original code and delete the un-used code. Any way that you slice it the original customer function becomes more and more like spaghetti every day. Documentation for the function has to change each time as well. With a class you can inherit all of the base class functionality into a new customer type. You do not have to break open the base class to add a case, you just have to create an extension class. Documentation is unique to each class. Stut has demonstrated an example of delegation. when used with objects, inheritance is not necessary, but it can be used if desired. use your polymorphic mechanism of choice :) -nathan
Re: [PHP] How to decode the PHP Source Code
On 10/12/07, tedd [EMAIL PROTECTED] wrote: At 9:57 AM -0400 10/11/07, Daniel Brown wrote: By the way, Tedd you alright there? Ya' kinda' got squashed. -- Daniel P. Brown I'm find, but I lost my thought -- it's happening more these days. :-) Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com I found a thought when I was drifting off to sleep last night. Maybe it was yours, tedd. But it was in a foreign language - looked like perl. Couldn't make heads or tails of it. David
Re: [PHP] How to decode the PHP Source Code
At 9:57 AM -0400 10/11/07, Daniel Brown wrote: By the way, Tedd you alright there? Ya' kinda' got squashed. -- Daniel P. Brown I'm find, but I lost my thought -- it's happening more these days. :-) 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] preg_match_all Help
[EMAIL PROTECTED] wrote: ... It would help to see the input text and to know exactly what you're trying to match. -- Richard Heyes +44 (0)800 0213 172 http://www.websupportsolutions.co.uk Knowledge Base and HelpDesk software that can cut the cost of online support -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] RE: round()
On 10/12/07, tedd [EMAIL PROTECTED] wrote: At 7:30 PM -0700 10/11/07, Instruct ICC wrote: Now I see why BCMath was mentioned. Yes, but precision is not the issue. It doesn't make any difference if you are rounding. (a) 1.489123451985765 or (b) 148912345198576.5 You still have to make a decision as to if the above (a) rounds to: (a) 1.48912345198577 or (a) 1.48912345198576 or the above (b) rounds to: (b)148912345198577 or (b) 148912345198576 It's a question of rounding, not precision. precision is still an issue; after a certain number of digits are used as the argument; round becomes inaccurate. from the cases you listed above (a) 1.489123451985765 bcmath results in one of the possible results you listed, (a) 1.48912345198577; round results in neither possible result. case (b) 148912345198576.5 bcmath results in one of the possible results, (b)148912345198577; round results in neither possible result. this is because the internal binary data type is already filled to capacity when these calculations are imposed on that data. im not sure how bcmath handles this internally, but it appears to be more precise and more accurate. results will vary based on your hardware, but you can use the second tool i passed out to find the breaking point on your system and the first one to test possibilities against the breaking point. [EMAIL PROTECTED] ~/working/www $ ./bcRound.php 1.489123451985765 14 round result: 1.48912345199 roundbc result: 1.48912345198577 Numerical Comparison: the results are the same String Comparison: the results are different [EMAIL PROTECTED] ~/working/www $ ./bcRound.php 148912345198576.5 0 round result: 148912345199000 roundbc result: 148912345198577. Numerical Comparison: the results are the same String Comparison: the results are different i cant seem to get bcmath to choose the alternate rounding path in either one of the cases. -nathan
RE: [PHP] Classes - Dumb question
[snip] First of all what you call normal is procedural or functional programming. There is nothing wrong with doing things this way and may be especially quick and efficient when doing basic web sites and applications. Document well and you will have no problem maintaining your code. One correction. What is being described is procedural or imperative programming. Functional programming is another beast entirely (closures, first-class functions, immutable variables, etc.). PHP is not a functional language by any stretch of the imagination. For functional programming, see Erlang, Haskel, ML, LISP, and to a lesser extent Javascript. [/snip] Thanks for the correction Larry, I knew the difference and just brain farted. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Filter input
At 5:17 PM +0200 10/11/07, Manuel Vacelet wrote: The thing that remains not very clear to me is where validation stop and where application logic start. Forgive me if I'm stating the obvious. For me, there isn't a variable that I receive in any of my scripts that I don't know what it should be (exact or range) and, as such, I filter accordingly. A very good book on this subject is Chris Shiflett's PHP Security (http://shiflett.org/). He uses a methodology of clean variables that answers the question you pose. As for me, the acquiring any variables outside my script requires checking -- it's a one part process and not two. 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] exit and ob_*
On 10/12/07, Robert Cummings [EMAIL PROTECTED] wrote: Have you checked your error log to see if there an error being generated that you can't see? Cheers, Rob. Yes, no unusual errors. The thing is... this wasn't an issue when I was developing on a Suse box running apache. Recently, I moved development over to Win 2k3 running IIS6. Since then, several issues have cropped up. =/ Think this could be IIS-related? ~Philip On Fri, 2007-10-12 at 14:03 -0500, Philip Thompson wrote: Hi. This is weird. Here's my structure. I have an index.php file that just includes the content depending on what page the user is on. So, because of potential redirection from those sub-pages, I call ob_start() before any output (in index.php). I'm doing some testing and I'm wanting to see what information's in a variable, etc. So, I display the variable contents and call 'exit' so that the page doesn't continue and get redirected elsewhere. However, when I call 'exit' on one of these sub-pages, I get no output from that sub-page. During testing, I took out the redirection and commented the exit line. The output displayed. Before commenting the exit function call, I called ob_clean to see if it had something to do with there being content in the buffer - the content of the sub-page showed WITH the exit. Why would no information show when calling exit(), even if ob_start had been called? I've never had to deal with this before. [examples] // This is content from a sub-page called from index.php [example code: does not work] echo 'hi'; exit; // 'hi' does NOT display ... [example code: does work] ob_clean(); echo 'hi'; exit; // 'hi' DOES display ... [/examples] I suppose this isn't a big deal during production, but during testing it's really frustrating. Does anyone have any suggestions as to why 'exit' is functioning (no pun intended) this way? Note: I do want what's currently in the buffer to be sent to the browser, so I don't want to have to call ob_clean. Any thoughts? Another person (*francois at bonzon dot com) *mentions this on the PHP exit page http://www.php.net/exit, but I'm still not sure why it happens. Thanks in advance, ~Philip -- ... SwarmBuy.com - http://www.swarmbuy.com Leveraging the buying power of the masses! ...
Re: [PHP] exit and ob_*
On 10/12/07, Philip Thompson [EMAIL PROTECTED] wrote: I suppose this isn't a big deal during production, but during testing it's really frustrating. Does anyone have any suggestions as to why 'exit' is functioning (no pun intended) this way? Note: I do want what's currently in the buffer to be sent to the browser, so I don't want to have to call ob_clean. Any thoughts? I don't know about the behavior, but if you want the contents to be sent, you can flush them using ob_flush() instead of clearing them with ob_clean(). Andrew -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Classes - Dumb question
[snip] Yes, but I could do that procedurally from within the customer function by simply adding a customer type (needed regardless) and using a switch to direct and collect the additional data needed. In either case, I still have to write more code to accommodate scaling. And, if I have more customer types, then it's a simple matter to add more customer functions and addition case statements to the initial customer function. I don't see the benefit in using a class. At this point, it just looks like a different way of doing things. [/snip] No doubt. (are you by chance continuing the other argument, re: interfaces?), but you have to break open the original tested function, add code to it, test it, etc. Every time you add a new case you have to break open the existing function to add that case. After a while, say if you need to drop a customer type you would have to (not really, you can leave it there and never exercise the case) break open the original code and delete the un-used code. Any way that you slice it the original customer function becomes more and more like spaghetti every day. Documentation for the function has to change each time as well. With a class you can inherit all of the base class functionality into a new customer type. You do not have to break open the base class to add a case, you just have to create an extension class. Documentation is unique to each class. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Classes - Dumb question
At 7:36 AM -0500 10/11/07, Jay Blanchard wrote: [snip] okay, this is really (!) embarassing, but I have to ask: Why would I want to use classes in PHP? I have been using PHP for years now and writing the normal functions all the time. I have never even bothered working with classes, but now I would love to know what makes the classes so special... Please go easy on me ;o) Just trying to make another step :o) [/snip] Do not be embarrassed, this is a very good question. First of all what you call normal is procedural or functional programming. There is nothing wrong with doing things this way and may be especially quick and efficient when doing basic web sites and applications. Document well and you will have no problem maintaining your code. OOP (object oriented programming) is especially useful when the application you have created needs to scale. A quick example; you have sold your products to the consumer market for a long time but now the commercial market has become interested. Commercial customers are different than non-commercial customers, different data, different credit requirements, different shipping, etc. but they still have a lot in common, If you had a class Customer you could extended that class to include commercial customers and only have to code for the unique qualities of that kind of customer. Then if another type of customer crops up, say a military contract, you could extend again; class Customer { } class CommercialCustomer extends Customer { /* *only code unique to commercial customers * inherits from Customer other variables * and functions that are common */ } class MilitaryCustomer extends Customer { /* *only code unique to military customers * inherits from Customer other variables * and functions that are common */ } Jay: Yes, but I could do that procedurally from within the customer function by simply adding a customer type (needed regardless) and using a switch to direct and collect the additional data needed. function customer($whatWas, $customertype, $whatAdditional) { /* do what was (i.e., common to all) */ /* then do what's additional unique to type */ switch(1) { case $customertype =='Commercial': commercialCustomer($whatAdditional); break; .. and so on } function commercialCustomer($whatAdditional) { /* *only code unique to commercial customers */ } function militaryCustomer($whatAdditional) { /* *only code unique to military customers */ } In either case, I still have to write more code to accommodate scaling. And, if I have more customer types, then it's a simple matter to add more customer functions and addition case statements to the initial customer function. I don't see the benefit in using a class. At this point, it just looks like a different way of doing things. 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] exit and ob_*
On Fri, 2007-10-12 at 14:30 -0500, Philip Thompson wrote: On 10/12/07, Robert Cummings [EMAIL PROTECTED] wrote: Have you checked your error log to see if there an error being generated that you can't see? Cheers, Rob. Yes, no unusual errors. The thing is... this wasn't an issue when I was developing on a Suse box running apache. Recently, I moved development over to Win 2k3 running IIS6. Since then, several issues have cropped up. =/ Think this could be IIS-related? No idea, I've never used IIS :) Cheers, Rob. -- ... SwarmBuy.com - http://www.swarmbuy.com Leveraging the buying power of the masses! ... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] RE: round()
At 11:26 AM -0700 10/11/07, =?UTF-8?Q?J=C3=BCrgen_Wind?= wrote: I get correct results: 5.2.4 PHP_VERSION round(5.555,2):5.56 toFixed(5.555,2):5.56 You get correct results because the demand you made of the function was simple. If you expand your demand to thousands of cases, then the bias will emerge. 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] exit and ob_*
On 10/12/07, Robert Cummings [EMAIL PROTECTED] wrote: On Fri, 2007-10-12 at 14:30 -0500, Philip Thompson wrote: On 10/12/07, Robert Cummings [EMAIL PROTECTED] wrote: Have you checked your error log to see if there an error being generated that you can't see? Cheers, Rob. Yes, no unusual errors. The thing is... this wasn't an issue when I was developing on a Suse box running apache. Recently, I moved development over to Win 2k3 running IIS6. Since then, several issues have cropped up. =/ Think this could be IIS-related? No idea, I've never used IIS :) Cheers, Rob. Oh lucky you! I'm drafting reasons on why we should switch to apache. I may have some leverage with this issue! ;-) Thanks for you help. Anyone else have some thoughts? ~Philip
Re: [PHP] exit and ob_*
Have you checked your error log to see if there an error being generated that you can't see? Cheers, Rob. On Fri, 2007-10-12 at 14:03 -0500, Philip Thompson wrote: Hi. This is weird. Here's my structure. I have an index.php file that just includes the content depending on what page the user is on. So, because of potential redirection from those sub-pages, I call ob_start() before any output (in index.php). I'm doing some testing and I'm wanting to see what information's in a variable, etc. So, I display the variable contents and call 'exit' so that the page doesn't continue and get redirected elsewhere. However, when I call 'exit' on one of these sub-pages, I get no output from that sub-page. During testing, I took out the redirection and commented the exit line. The output displayed. Before commenting the exit function call, I called ob_clean to see if it had something to do with there being content in the buffer - the content of the sub-page showed WITH the exit. Why would no information show when calling exit(), even if ob_start had been called? I've never had to deal with this before. [examples] // This is content from a sub-page called from index.php [example code: does not work] echo 'hi'; exit; // 'hi' does NOT display ... [example code: does work] ob_clean(); echo 'hi'; exit; // 'hi' DOES display ... [/examples] I suppose this isn't a big deal during production, but during testing it's really frustrating. Does anyone have any suggestions as to why 'exit' is functioning (no pun intended) this way? Note: I do want what's currently in the buffer to be sent to the browser, so I don't want to have to call ob_clean. Any thoughts? Another person (*francois at bonzon dot com) *mentions this on the PHP exit page http://www.php.net/exit, but I'm still not sure why it happens. Thanks in advance, ~Philip -- ... SwarmBuy.com - http://www.swarmbuy.com Leveraging the buying power of the masses! ... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] round()
Yes, but precision is not the issue. It doesn't make any difference if you are rounding. You still have to make a decision Uuhm, what was $t on the platform before the round please (the += .000..1 post)? Then that will confirm that precision is not the problem. Also, making a decision is setting the optional precision value in the round function. _ Climb to the top of the charts! Play Star Shuffle: the word scramble challenge with star power. http://club.live.com/star_shuffle.aspx?icid=starshuffle_wlmailtextlink_oct
[PHP] exit and ob_*
Hi. This is weird. Here's my structure. I have an index.php file that just includes the content depending on what page the user is on. So, because of potential redirection from those sub-pages, I call ob_start() before any output (in index.php). I'm doing some testing and I'm wanting to see what information's in a variable, etc. So, I display the variable contents and call 'exit' so that the page doesn't continue and get redirected elsewhere. However, when I call 'exit' on one of these sub-pages, I get no output from that sub-page. During testing, I took out the redirection and commented the exit line. The output displayed. Before commenting the exit function call, I called ob_clean to see if it had something to do with there being content in the buffer - the content of the sub-page showed WITH the exit. Why would no information show when calling exit(), even if ob_start had been called? I've never had to deal with this before. [examples] // This is content from a sub-page called from index.php [example code: does not work] echo 'hi'; exit; // 'hi' does NOT display ... [example code: does work] ob_clean(); echo 'hi'; exit; // 'hi' DOES display ... [/examples] I suppose this isn't a big deal during production, but during testing it's really frustrating. Does anyone have any suggestions as to why 'exit' is functioning (no pun intended) this way? Note: I do want what's currently in the buffer to be sent to the browser, so I don't want to have to call ob_clean. Any thoughts? Another person (*francois at bonzon dot com) *mentions this on the PHP exit page http://www.php.net/exit, but I'm still not sure why it happens. Thanks in advance, ~Philip
Re: [PHP] exit and ob_*
On 10/12/07, Andrew Ballard [EMAIL PROTECTED] wrote: On 10/12/07, Philip Thompson [EMAIL PROTECTED] wrote: I suppose this isn't a big deal during production, but during testing it's really frustrating. Does anyone have any suggestions as to why 'exit' is functioning (no pun intended) this way? Note: I do want what's currently in the buffer to be sent to the browser, so I don't want to have to call ob_clean. Any thoughts? I don't know about the behavior, but if you want the contents to be sent, you can flush them using ob_flush() instead of clearing them with ob_clean(). Andrew That's the issue. The contents from the super page (index.php) ARE being flushed. However, the contents of the sub-pages are NOT being flushed - nothing is displayed. That's why this is weird. Some of the buffer is flushed, but not the whole thing. Or, the contents of the sub-pages are making it into the buffer (which makes no sense - size is definitely not an issue). However, I did call ob_flush to see if this would work. Nope. It didn't make a difference. But this makes sense b/c the contents of the super-page are already flushed. Blegh!!! This is frustrating. Is happy hour here yet?! ~Philip
RE: [PHP] round()
Yes, but precision is not the issue. php -r '$t=123.45; echo $t . \n; $t+=0.001; echo $t . \n;' 123.45 123.451 php -r '$t=123.45; echo $t . \n; $t+=0.0001; echo $t . \n;' 123.45 123.45 php -r '$t=123.45678901234567; echo $t . \n;' 123.45678901235 Geee garbage in, garbage out. round would have been given garbage to process depending upon the precision desired. Anyway, you can still believe what you want. I see others agree. _ Help yourself to FREE treats served up daily at the Messenger Café. Stop by today. http://www.cafemessenger.com/info/info_sweetstuff2.html?ocid=TXT_TAGLM_OctWLtagline
[PHP] header error without whitespace issue
Error = WARNING: Cannot modify header information - headers already sent by (output started at /home/zoneof5/public_html/index-dev.html:10) in line 1528 of file common.inc.php Which comes from me trying to take a login script and put it into an existing .html file with .htaccess configured to parse php scripts. Research yields that the header needs to be loaded before anything. The header is being called by another file “common.inc.php” How do I safely extract this call from the existing script and place the call at the beginning of the .html or just simply fix the error? Php code; ?php include('./amember/config.inc.php'); $t = new_smarty(); $_product_id = array('ONLY_LOGIN'); if (isset($_REQUEST['amember_redirect_url'])) $_SESSION['amember_redirect_url'] = $_REQUEST['amember_redirect_url']; function rcmp_begin_date($a, $b){ return strcmp($b['begin_date'], $a['begin_date']); } include($config['plugins_dir']['protect'] . '/php_include/check.inc.php'); $payments = $db-get_user_payments(intval($_SESSION['_amember_id']), 1); usort($payments, 'rcmp_begin_date'); $now = date('Y-m-d'); $urls = array(); foreach ($payments as $k=$v){ if (($v['expire_date'] = $now) ($v['begin_date'] = $now)) { $p = get_product($v['product_id']); $url = $p-config['url']; if (strlen($url)){ $urls[] = $url; } } } if ($_SESSION['amember_redirect_url']) { $redirect = $_SESSION['amember_redirect_url']; unset($_SESSION['amember_redirect_url']); } elseif (count(array_unique($urls)) == 1){ if (in_array('htpasswd_secure', $plugins['protect'])){ $member_login_pw = htpasswd_secure_get_login($_SESSION['_amember_user']['login']). ':'. htpasswd_secure_get_passwd($_SESSION['_amember_user']['pass']); $redirect = add_password_to_url($urls[0], $member_login_pw); } else { if ($config['display_member_pw_urls']) { $member_login_pw = $_SESSION['_amember_user']['login']. ':'. $_SESSION['_amember_user']['pass']; $redirect = add_password_to_url($urls[0], $member_login_pw); } else { $redirect = add_password_to_url($urls[0]); } } } else { $redirect = $config['root_url'] . /amember/member.php; } #print_r($urls); html_redirect($redirect, 0, 'Redirect', _LOGIN_REDIRECT); ? No virus found in this outgoing message. Checked by AVG Free Edition. Version: 7.5.488 / Virus Database: 269.14.8/1064 - Release Date: 10/11/2007 3:09 PM
Re: [PHP] A two flavored post
In addition to what everyone else has suggested you probably also want to have your page work for people without javascript enabled, or the handicapped. One way you could do this is have a div and the PHP generates the div where you would put the link, with code for the link inside with the PHP variable so you have -- | abc.com/?a=value | -- the div wouldn't really have a border, it's just there so you can see it. Anyway, for those lucky people who have JavaScript enabled you could simply use JS to change the innerhtml of the div to have the new JS generated link. - Dan Nathan Nobbe [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] On 10/4/07, tedd [EMAIL PROTECTED] wrote: Hi gang: I asked this question on the javascript list, but for some reason it's taking forever to post there. So, I figured that I would ask here as well. I'm currently sending data (the value of s) to another script via the html statement: a href=img.php?s=?php echo($value);?Click here/a However, I need to add another variable, namely a javascript variable, to the GET string. How can I send both a php and a javascript variable together at the same time? the question is when is the variable you want to append available to the javascript. as soon as you get the variable in the javascript the next thing you can do is append it to the value of the href attribute of the a tag. html head script type=text/javascript window.onload = function() { var someLinkHref = document.getElementById('someLink').href; someLinkHref += anotherVar=8; alert(someLinkHref); } /script /head body a id=someLink href=http://somesite.com?a=5; click here /a /body /html if you want to use the onclick event handler as rob suggested, you could stash the variable in the Window global object, then reference it in the implementation of the onclick function (though i still have mixed feelings about that approach [the Window object part that is]). -nathan -nathan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: RE: [PHP] round()
At 11:08 AM -0700 10/12/07, =?UTF-8?Q?J=C3=BCrgen_Wind?= wrote: It's a question of what you expect from a rounding function. If you work with reals on a computer you always have a bit of fuzzynes due to the internal conversions from float to binary and resulting truncations. It is only reals that use a rounding function. If you need reproducable results which fit your expectations and if speed doesn't matter just use your own routine depending on string comparison. Yes, I can round my own -- one that is more accurate than round(). But, I was wondering if others had observed that round() was not as accurate as other methods -- and that was the point of my initial post. 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] round()
At 12:55 PM -0700 10/12/07, Instruct ICC wrote: Yes, but precision is not the issue. php -r '$t=123.45; echo $t . \n; $t+=0.001; echo $t . \n;' 123.45 123.451 php -r '$t=123.45; echo $t . \n; $t+=0.0001; echo $t . \n;' 123.45 123.45 php -r '$t=123.45678901234567; echo $t . \n;' 123.45678901235 Geee garbage in, garbage out. round would have been given garbage to process depending upon the precision desired. Anyway, you can still believe what you want. I see others agree. Never mind. 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] Classes - Dumb question
At 2:44 PM +0100 10/12/07, Stut wrote: You can limit the need to add more code like so... function customer($whatWas, $customertype, $whatAdditional) { /* do what was (i.e., common to all) */ /* then do what's additional unique to type */ $func = strtolower($customertype).'Customer'; $func($whatAdditional); } That's something I haven't seen before (in this language) -- that's slick. Thanks, 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] Classes - Dumb question
At 9:03 AM -0500 10/12/07, Jay Blanchard wrote: tedd said: In either case, I still have to write more code to accommodate scaling. And, if I have more customer types, then it's a simple matter to add more customer functions and addition case statements to the initial customer function. I don't see the benefit in using a class. At this point, it just looks like a different way of doing things. [/snip] No doubt. (are you by chance continuing the other argument, re: interfaces?) No, I didn't really understand the argument anyway. An interface to me currently is what the user uses to trigger my scripts. , but you have to break open the original tested function, add code to it, test it, etc. Every time you add a new case you have to break open the existing function to add that case. After a while, say if you need to drop a customer type you would have to (not really, you can leave it there and never exercise the case) break open the original code and delete the un-used code. Any way that you slice it the original customer function becomes more and more like spaghetti every day. Documentation for the function has to change each time as well. Every time you add more code, the documentation should change regardless. Every time you add more code, you have to test it anyway. Spaghetti is not caused by adding more code, but by poor design. With a class you can inherit all of the base class functionality into a new customer type. You do not have to break open the base class to add a case, you just have to create an extension class. Documentation is unique to each class. No matter what, you have to break something open to add code -- if nothing else, the script. I do see and understand the methodology afforded by OOP, but, I don't see an overwhelming reason to use it. Maybe in my next decade of programming I'll get with the program. After all, I don't keypunch anymore and that's progress. :-) 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