[PHP] PHP, OOP and AJAX
Update. Hello Everyone, First of all, thank you all for your input. I ran a sinmple test using the suggestions you gave me and and require_once. Using firebug to test the output, I got an internal server error. I found out what the problem was. What I am doing is I have classes which represent the objects, another class containing the functions. From the function class I create an instance of each object, manipulate the information, return the HTML result. Finally I have a runner class that creates an instance of the function class, calls the function required and outputs the information. What the problem was for some reason I was did not create an instance of the function class, just was calling the function. Well by creating the runner class I solved the problem. Thanks all for your help. Regards Julian
[PHP] PHP, OOP and AJAX
Hi Everyone, This is the first time that I am posting in the PHP forum, so hope that I am osting in the right place. I would like to say that before submitting to this forum I have done some research looking for a solution without success. I had been programming in ASP.NET for years using Object Oriented Princeliness but decided to walk away from that. I am now researching and specialising in the open source world. I have started to develop a project using MySQL, PHP and OOP. So far I have succeed. However I got stuck once I started implement AJAX using the AJAX tutorial from w3schools.com. What I have discovered is: for some reason when you call a file that requires other fies using the REQUIRE or INCLUDE it just does not work. I can conform this as I have tested with out the the functions. Has anyone ever meet such a situation can you give me some feedback please. Thank you very much in advance for your support. Regards Julian
Re: [PHP] PHP, OOP and AJAX
On 5/28/09 7:31 AM, Julian Muscat Doublesin opensourc...@gmail.com wrote: I had been programming in ASP.NET for years using Object Oriented Princeliness but decided to walk away from that. I am now researching and specialising in the open source world. yay! I have started to develop a project using MySQL, PHP and OOP. oh. not walking away from oop after all? sad ;-) So far I have succeed. However I got stuck once I started implement AJAX using the AJAX tutorial from w3schools.com. if using ajax, i recommend you take a look at jquery. i'm really quite taken with it. it makes browser-independent ajax much easier. What I have discovered is: for some reason when you call a file that requires other fies using the REQUIRE or INCLUDE it just does not work. I can conform this as I have tested with out the the functions. i can't imagine a reason why an include would fail because the script was invoked via XHR. my ajax back-end php scripts use included files. are you sure this isn't a problem with the include path? to debug you could try writing ini_get('include_path') to your log file. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP OOP
On Mon, Feb 9, 2009 at 11:12 AM, Yannick Mortier mvmort...@googlemail.comwrote: 2009/2/9 tedd t...@sperling.com: snip Yes C++ is not bad for this, but it has also got some flaws. What language doesn't have flaws, dude? Out of all the OOP C++ and java are probably the most solid. And I _hate_ java... However, while I don't know PHP OOP, I am open to considering it because of the proliferation of web based applications. My personal opinion is that's where all programming is headed anyway, but that's just my opinion. With that said, what's the differences and advantages/disadvantages between C++ and PHP OOP? Cheers, tedd Both of them have got the disadvantage that they also support procedural programming. Some of your students will for sure not understand OOP immediately and they'll avoid using it this way. I guess Java is really a good idea, there are some great Editors around for it (Netbeans...) It's completely OOP and there are many great tutorials for it in the net, so a willing student can easily go on after the class is over. I really didn't like Java some months ago, but I have to learn it at school myself now and I think it's great to learn. It avoids most of the errors that come from C++'s pointers etc. so you can really focus on teaching OOP and not why you must always reserve memory etc. Later on it'll sure be easy to switch to other languages (though I can't really tell this because I started with C++ when I was ten years old and discovered PHP later and get to know Java know) So: My vote goes to Java, or if you want a decision between C++ and PHP it's C++. -- Currently developing a browsergame... http://www.p-game.de Trade - Expand - Fight Follow me at twitter! http://twitter.com/moortier -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Kyle Terry | www.kyleterry.com Help kick start VOOM (Very Open Object Model) for a library of PHP classes. http://www.voom.me | IRC EFNet #voom
Re: [PHP] PHP OOP
Java is really awesome at OOP and it is great for teaching OOP or, shall we say illustrating OOP. OOP is a programming technique in general without any bias towards any programming language. Good background on OOP concepts is essential in learning language specific OOP implementation. So don't worry about languages. The important thing is, you know what OOP means. Also you can't compare PHP to other programming languages. PHP is new and mainly built for the web. With its raw power, it is simply incomparable. virgil http://www.jampmark.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP OOP
Paul M Foster wrote: On Mon, Feb 09, 2009 at 11:02:37AM -0500, tedd wrote: As a side note, I think students should learn a language like C before learning something like Perl, Python or PHP. Having to deal with defining/declaring variables and their storage methods before use I think makes for more conscientious programmers. And pointers are an education all on their own. ;-} For teaching programming or OOP I would choose a language which concentrates on the topic. The hard stuff, which you have to deal with in C for example, can be learned later. I'm glad that I started programming in Pascal, not in C. If today I had to learn programming as such I would definitively opt for Python! My choice for learning OOP would be Python or even better Java cause you don't have the choice to do it in a procedural way. Marcus -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP OOP
Marcus Gnaß schrieb: Paul M Foster wrote: On Mon, Feb 09, 2009 at 11:02:37AM -0500, tedd wrote: As a side note, I think students should learn a language like C before learning something like Perl, Python or PHP. Having to deal with defining/declaring variables and their storage methods before use I think makes for more conscientious programmers. And pointers are an education all on their own. ;-} For teaching programming or OOP I would choose a language which concentrates on the topic. The hard stuff, which you have to deal with in C for example, can be learned later. I'm glad that I started programming in Pascal, not in C. If today I had to learn programming as such I would definitively opt for Python! My choice for learning OOP would be Python or even better Java cause you don't have the choice to do it in a procedural way. Marcus Hi @ all, but this is a php list... Regards Carlos -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP OOP
Where I study, Intro to OOP is taught in C# using Visual Studio 2003 and further OOP concepts are taught in Java, with the academic computer science of OOP alongside. On Wed, Feb 11, 2009 at 2:40 AM, Carlos Medina i...@simply-networks.dewrote: Marcus Gnaß schrieb: Paul M Foster wrote: On Mon, Feb 09, 2009 at 11:02:37AM -0500, tedd wrote: As a side note, I think students should learn a language like C before learning something like Perl, Python or PHP. Having to deal with defining/declaring variables and their storage methods before use I think makes for more conscientious programmers. And pointers are an education all on their own. ;-} For teaching programming or OOP I would choose a language which concentrates on the topic. The hard stuff, which you have to deal with in C for example, can be learned later. I'm glad that I started programming in Pascal, not in C. If today I had to learn programming as such I would definitively opt for Python! My choice for learning OOP would be Python or even better Java cause you don't have the choice to do it in a procedural way. Marcus Hi @ all, but this is a php list... Regards Carlos -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- I'm going out to find myself, if you see me here, keep me here untill I can catch up If I haven't said so already, Thanks Byron
Re: [PHP] PHP OOP
On Tue, Feb 10, 2009 at 8:40 AM, Carlos Medina i...@simply-networks.de wrote: Marcus Gnaß schrieb: Paul M Foster wrote: On Mon, Feb 09, 2009 at 11:02:37AM -0500, tedd wrote: As a side note, I think students should learn a language like C before learning something like Perl, Python or PHP. Having to deal with defining/declaring variables and their storage methods before use I think makes for more conscientious programmers. And pointers are an education all on their own. ;-} For teaching programming or OOP I would choose a language which concentrates on the topic. The hard stuff, which you have to deal with in C for example, can be learned later. I'm glad that I started programming in Pascal, not in C. If today I had to learn programming as such I would definitively opt for Python! My choice for learning OOP would be Python or even better Java cause you don't have the choice to do it in a procedural way. Marcus Hi @ all, but this is a php list... Regards Carlos Yes, it is, but the original question was about OOP and not specifically about PHP. It seems fair enough to me for someone to ask the question on this list since PHP was one of the languages being considered, even if consensus among the list seems to be that PHP would not be the best choice for teaching a course on OOP. Andrew -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP OOP
At 9:36 AM -0500 2/10/09, Andrew Ballard wrote: On Tue, Feb 10, 2009 at 8:40 AM, Carlos Medina i...@simply-networks.de wrote: Marcus Gnaß schrieb: Hi @ all, but this is a php list... Regards Carlos Yes, it is, but the original question was about OOP and not specifically about PHP. It seems fair enough to me for someone to ask the question on this list since PHP was one of the languages being considered, even if consensus among the list seems to be that PHP would not be the best choice for teaching a course on OOP. Andrew Andrew: Absolutely, you're not out of line at all. TI have found in my life that there will always be those who have a better idea, if you know what I mean. The point of the post (me being the OP) was to sample other people's opinion as to what would be best language to use to teach OOP, and that included considering php, thus the relevancy. The answer turns out to be Java (1) or C++ (2) depending upon the environment and availability of resources. Why people have to get on and comment that this is a php list is beyond me, duh. 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] PHP OOP
A loosely typed language like PHP might not be the best choice for teaching OOP, because even though PHP makes it easier with loose types, you should know about them and how they are stored etc. PHP is a great language but maybe not strict enough for students to understand all the errors that can occur. I would recommend encouraging learning PHP though as it has become both an important and fast and easy language to program in. For that it's also amazingly fast in execution. Cheers, Tim Tim-Hinnerk Heuer http://www.ihostnz.com Garry Shandling - I'm dating a woman now who, evidently, is unaware of it. 2009/2/11 tedd tedd.sperl...@gmail.com At 9:36 AM -0500 2/10/09, Andrew Ballard wrote: On Tue, Feb 10, 2009 at 8:40 AM, Carlos Medina i...@simply-networks.de wrote: Marcus Gnaß schrieb: Hi @ all, but this is a php list... Regards Carlos Yes, it is, but the original question was about OOP and not specifically about PHP. It seems fair enough to me for someone to ask the question on this list since PHP was one of the languages being considered, even if consensus among the list seems to be that PHP would not be the best choice for teaching a course on OOP. Andrew Andrew: Absolutely, you're not out of line at all. TI have found in my life that there will always be those who have a better idea, if you know what I mean. The point of the post (me being the OP) was to sample other people's opinion as to what would be best language to use to teach OOP, and that included considering php, thus the relevancy. The answer turns out to be Java (1) or C++ (2) depending upon the environment and availability of resources. Why people have to get on and comment that this is a php list is beyond me, duh. 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 OOP
Hi gang: At the college where I teach, they are considering teaching OOP, but they don't want to settle on a specific language. My thoughts are it's difficult to teach OOP without a language -- while the general concepts of OOP are interesting, people need to see how concepts are applied to understand how they work -- thus I think a specific language is required I lean toward C++ because I wrote in it for a few years AND C++ appears to be the most common, widespread, and popular OOP language. However, while I don't know PHP OOP, I am open to considering it because of the proliferation of web based applications. My personal opinion is that's where all programming is headed anyway, but that's just my opinion. With that said, what's the differences and advantages/disadvantages between C++ and PHP OOP? 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] PHP OOP
On Mon, Feb 9, 2009 at 8:02 AM, tedd t...@sperling.com wrote: Hi gang: At the college where I teach, they are considering teaching OOP, but they don't want to settle on a specific language. My thoughts are it's difficult to teach OOP without a language -- while the general concepts of OOP are interesting, people need to see how concepts are applied to understand how they work -- thus I think a specific language is required I lean toward C++ because I wrote in it for a few years AND C++ appears to be the most common, widespread, and popular OOP language. However, while I don't know PHP OOP, I am open to considering it because of the proliferation of web based applications. My personal opinion is that's where all programming is headed anyway, but that's just my opinion. With that said, what's the differences and advantages/disadvantages between C++ and PHP OOP? 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 In my personal opinion, C++ would probably be the best language to teach OOP concepts in. That or Python. -- Kyle Terry | www.kyleterry.com Help kick start VOOM (Very Open Object Model) for a library of PHP classes. http://www.voom.me | IRC EFNet #voom -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP OOP
Hi gang: At the college where I teach, they are considering teaching OOP, but they don't want to settle on a specific language. My thoughts are it's difficult to teach OOP without a language -- while the general concepts of OOP are interesting, people need to see how concepts are applied to understand how they work -- thus I think a specific language is required I lean toward C++ because I wrote in it for a few years AND C++ appears to be the most common, widespread, and popular OOP language. However, while I don't know PHP OOP, I am open to considering it because of the proliferation of web based applications. My personal opinion is that's where all programming is headed anyway, but that's just my opinion. With that said, what's the differences and advantages/disadvantages between C++ and PHP OOP? Cheers, tedd IMHO I think that you are right about using a specific language and you should strongly insist on that. Someone needs to see how objects are taking flesh and bones in real life and not just theoretically. You could consider Java as well before taking your final decision. -- Thodoris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP OOP
On Mon, Feb 9, 2009 at 11:20 AM, Thodoris t...@kinetix.gr wrote: Hi gang: At the college where I teach, they are considering teaching OOP, but they don't want to settle on a specific language. My thoughts are it's difficult to teach OOP without a language -- while the general concepts of OOP are interesting, people need to see how concepts are applied to understand how they work -- thus I think a specific language is required I lean toward C++ because I wrote in it for a few years AND C++ appears to be the most common, widespread, and popular OOP language. However, while I don't know PHP OOP, I am open to considering it because of the proliferation of web based applications. My personal opinion is that's where all programming is headed anyway, but that's just my opinion. With that said, what's the differences and advantages/disadvantages between C++ and PHP OOP? Cheers, tedd IMHO I think that you are right about using a specific language and you should strongly insist on that. Someone needs to see how objects are taking flesh and bones in real life and not just theoretically. You could consider Java as well before taking your final decision. -- Thodoris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Especially since PHP is trying to be Java. :) -- http://www.voom.me | EFnet: #voom -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP OOP
Eric Butera wrote: On Mon, Feb 9, 2009 at 11:20 AM, Thodoris t...@kinetix.gr wrote: Hi gang: At the college where I teach, they are considering teaching OOP, but they don't want to settle on a specific language. My thoughts are it's difficult to teach OOP without a language -- while the general concepts of OOP are interesting, people need to see how concepts are applied to understand how they work -- thus I think a specific language is required I lean toward C++ because I wrote in it for a few years AND C++ appears to be the most common, widespread, and popular OOP language. However, while I don't know PHP OOP, I am open to considering it because of the proliferation of web based applications. My personal opinion is that's where all programming is headed anyway, but that's just my opinion. With that said, what's the differences and advantages/disadvantages between C++ and PHP OOP? Cheers, tedd IMHO I think that you are right about using a specific language and you should strongly insist on that. Someone needs to see how objects are taking flesh and bones in real life and not just theoretically. You could consider Java as well before taking your final decision. -- Thodoris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Especially since PHP is trying to be Java. :) take a wild guess as to what I'm going to day.. java is v good language to learn OO specific principals and I'd strongly recommend it - while I may get more done with php oo practically, I learn and undertand a lot more with java. regards! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP OOP
tedd wrote: I lean toward C++ because I wrote in it for a few years AND C++ appears to be the most common, widespread, and popular OOP language. I would agree, although I suspect Java is also a good candidate. However, while I don't know PHP OOP, I am open to considering it because of the proliferation of web based applications. Don't - compile-time type checking is essential to OOP. My personal opinion is that's where all programming is headed anyway, but that's just my opinion. Which you're certainly entitled to - I just can't quite see the Linux kernel or bind or an audio driver written as a web-app :-) /Per -- Per Jessen, Zürich (1.6°C) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP OOP
tedd wrote: I lean toward C++ because I wrote in it for a few years AND C++ appears to be the most common, widespread, and popular OOP language. I would agree, although I suspect Java is also a good candidate. However, while I don't know PHP OOP, I am open to considering it because of the proliferation of web based applications. Don't - compile-time type checking is essential to OOP. My personal opinion is that's where all programming is headed anyway, but that's just my opinion. Which you're certainly entitled to - I just can't quite see the Linux kernel or bind or an audio driver written as a web-app or in php :-) /Per -- Per Jessen, Zürich (1.6°C) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP OOP
2009/2/9 tedd t...@sperling.com: Hi gang: At the college where I teach, they are considering teaching OOP, but they don't want to settle on a specific language. My thoughts are it's difficult to teach OOP without a language -- while the general concepts of OOP are interesting, people need to see how concepts are applied to understand how they work -- thus I think a specific language is required I lean toward C++ because I wrote in it for a few years AND C++ appears to be the most common, widespread, and popular OOP language. However, while I don't know PHP OOP, I am open to considering it because of the proliferation of web based applications. My personal opinion is that's where all programming is headed anyway, but that's just my opinion. With that said, what's the differences and advantages/disadvantages between C++ and PHP OOP? C++ is a good option, but if OOP is the focus it might be better to use Java or similar where you don't need to worry so much about memory management. If you're dealing with people who know C then C++ will work well, otherwise not. The worst thing you can do is skip over the details of C++ development because you want to focus on OOP. You'll end up with a bunch of people who *think* they can code in C++ but really haven't got a clue. Personally I'd have preferred my university to use Smalltalk, but none of the professors knew it so I had to teach myself. It's the original and IMHO still the best implementation of OOP concepts around. -Stuart -- http://stut.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP OOP
On Mon, Feb 09, 2009 at 11:02:37AM -0500, tedd wrote: Hi gang: At the college where I teach, they are considering teaching OOP, but they don't want to settle on a specific language. My thoughts are it's difficult to teach OOP without a language -- while the general concepts of OOP are interesting, people need to see how concepts are applied to understand how they work -- thus I think a specific language is required I lean toward C++ because I wrote in it for a few years AND C++ appears to be the most common, widespread, and popular OOP language. However, while I don't know PHP OOP, I am open to considering it because of the proliferation of web based applications. My personal opinion is that's where all programming is headed anyway, but that's just my opinion. With that said, what's the differences and advantages/disadvantages between C++ and PHP OOP? I don't know Java, but I suspect it's a more purely OO language than C++. I *have* coded in C++, and the OO aspects of C++ are like a bolt-on on the C language. There are some odd aspects of C++ because of its history as originally a preprocessor hack on top of C. PHP is *not* a good example for OO. There are a lot of OO principles it doesn't follow. I would have suggested Smalltalk, the original OO language, except that no one uses it any more, and other languages don't necessarily fully implement OO as done in Smalltalk. You're right about using a language which implements OO in a realistic way for today's programmers. I also agree you need a language in which to teach OO. Otherwise, this is all just theory, and won't stick with the students. Imagine learning algebra but never solving equations in the class. You'd forget the whole thing ten minutes after the class was over. In fact, it seems a little backward to teach OO programming as a lone subject. I would instead opt for teaching a language first, and OO as a secondary part of that course. Learning C++ will go a long way in assisting the student to learn Java, or vice versa. My experience programming C has been invaluable in coding under PHP. As a side note, I think students should learn a language like C before learning something like Perl, Python or PHP. Having to deal with defining/declaring variables and their storage methods before use I think makes for more conscientious programmers. And pointers are an education all on their own. ;-} Paul -- Paul M. Foster -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP OOP
On Mon, Feb 9, 2009 at 12:19 PM, Stuart stut...@gmail.com wrote: 2009/2/9 tedd t...@sperling.com: Hi gang: At the college where I teach, they are considering teaching OOP, but they don't want to settle on a specific language. My thoughts are it's difficult to teach OOP without a language -- while the general concepts of OOP are interesting, people need to see how concepts are applied to understand how they work -- thus I think a specific language is required I lean toward C++ because I wrote in it for a few years AND C++ appears to be the most common, widespread, and popular OOP language. However, while I don't know PHP OOP, I am open to considering it because of the proliferation of web based applications. My personal opinion is that's where all programming is headed anyway, but that's just my opinion. With that said, what's the differences and advantages/disadvantages between C++ and PHP OOP? C++ is a good option, but if OOP is the focus it might be better to use Java or similar where you don't need to worry so much about memory management. If you're dealing with people who know C then C++ will work well, otherwise not. The worst thing you can do is skip over the details of C++ development because you want to focus on OOP. You'll end up with a bunch of people who *think* they can code in C++ but really haven't got a clue. Personally I'd have preferred my university to use Smalltalk, but none of the professors knew it so I had to teach myself. It's the original and IMHO still the best implementation of OOP concepts around. -Stuart -- http://stut.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Actually I made up the term object-oriented, and I can tell you I did not have C++ in mind. http://video.google.com/videoplay?docid=-2950949730059754521 http://en.wikiquote.org/wiki/Alan_Kay -- http://www.voom.me | EFnet: #voom -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP OOP
Paul M Foster wrote: PHP is *not* a good example for OO. There are a lot of OO principles it doesn't follow. I would have suggested Smalltalk, the original OO language, except that no one uses it any more, and other languages don't necessarily fully implement OO as done in Smalltalk. You're right about using a language which implements OO in a realistic way for today's programmers. Depends exactly what Tedds class is meant to be - whether it's about programming or computer science. For the latter, Eiffel is also a good OO language. /Per -- Per Jessen, Zürich (1.9°C) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP OOP
2009/2/9 tedd t...@sperling.com: Hi gang: At the college where I teach, they are considering teaching OOP, but they don't want to settle on a specific language. I guess that is not a good idea, you should really combine it with a language, as some students will be curious enough to play around with it at home and so they'll also learn more. My thoughts are it's difficult to teach OOP without a language -- while the general concepts of OOP are interesting, people need to see how concepts are applied to understand how they work -- thus I think a specific language is required I lean toward C++ because I wrote in it for a few years AND C++ appears to be the most common, widespread, and popular OOP language. Yes C++ is not bad for this, but it has also got some flaws. However, while I don't know PHP OOP, I am open to considering it because of the proliferation of web based applications. My personal opinion is that's where all programming is headed anyway, but that's just my opinion. With that said, what's the differences and advantages/disadvantages between C++ and PHP OOP? Cheers, tedd Both of them have got the disadvantage that they also support procedural programming. Some of your students will for sure not understand OOP immediately and they'll avoid using it this way. I guess Java is really a good idea, there are some great Editors around for it (Netbeans...) It's completely OOP and there are many great tutorials for it in the net, so a willing student can easily go on after the class is over. I really didn't like Java some months ago, but I have to learn it at school myself now and I think it's great to learn. It avoids most of the errors that come from C++'s pointers etc. so you can really focus on teaching OOP and not why you must always reserve memory etc. Later on it'll sure be easy to switch to other languages (though I can't really tell this because I started with C++ when I was ten years old and discovered PHP later and get to know Java know) So: My vote goes to Java, or if you want a decision between C++ and PHP it's C++. -- Currently developing a browsergame... http://www.p-game.de Trade - Expand - Fight Follow me at twitter! http://twitter.com/moortier -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP OOP
On Monday 09 February 2009 10:02:37 am tedd wrote: Hi gang: At the college where I teach, they are considering teaching OOP, but they don't want to settle on a specific language. My thoughts are it's difficult to teach OOP without a language -- while the general concepts of OOP are interesting, people need to see how concepts are applied to understand how they work -- thus I think a specific language is required I lean toward C++ because I wrote in it for a few years AND C++ appears to be the most common, widespread, and popular OOP language. However, while I don't know PHP OOP, I am open to considering it because of the proliferation of web based applications. My personal opinion is that's where all programming is headed anyway, but that's just my opinion. With that said, what's the differences and advantages/disadvantages between C++ and PHP OOP? Cheers, tedd I definitely agree that teaching OOP without a language to write it in is a very stupid idea. However, part of the problem is that there is in practice no one version of OOP. Java is probably the best example of academically pure classic OOP (that is, class-based). That can be good for teaching, but it can also suck for developing because you have to do things in an academically formal way. Javascript, on the other hand, is a prototype-based language. Technically that's also OOP, or can be, but the code is entirely different conceptually when functions, methods, objects, and classes are all the same thing. :-) PHP's OOP is very closely modeled on Java's, but with some interesting additions. PHP 5.3 adds a few more and 5.4/6.0 is likely to add traits, which are another animal entirely. PHP is also a hybrid language and, by nature of being a shared-nothing scripting language OOP is often the wrong choice because of the setup and initialization costs. C++ has a little of each, albeit in a frequently convoluted way. It also has about 30 more types of access control than any other language I know, for better or worse. LISP is its own creature, closer to Javascript than to anything else I just mentioned. (Or arguably Javascript is closer to LISP.) Personally, I recommend teaching programming first in C++. Force them to do the hard stuff so they appreciate what the runtime is doing for them in higher level languages. It also means you can teach procedural and OOP in the same syntax. Then once they've gotten a few bruises in C++, expose them to Java, Javascript, PHP, etc. to let them see what higher level work actually gets done in these days. -- Larry Garfield la...@garfieldtech.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] php OOP book ¿...?
I´m looking for a book dedicated to OOP in PHP ... Now I´m reading ¨Core PHP Programming (Third Edition) (2003)¨ but it has just a few information about OOP. Do you know another book? ¿Do you have it? If anyone wants this book (Core PHP Programming (Third Edition) (2003)) just email me ... I´ll send it ... Best regards Enrique
[PHP] PHP OOP Question
Is it bad practice for a class to have a variable and method of the same name? Well, it's a matter of opinion what is and isn't bad practice, but personally I would never give a variable and a function the same name - if only to avoid confusion (PHP shouldn't mind if you do so though). Paul -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP OOP Question
Is it bad practice for a class to have a variable and method of the same name? For example: class product { var $Name; function Name() { return stripslashes($this-Name); } } Thanks, -Ed This message was sent using IMP, the Internet Messaging Program. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP OOP
I'm working for the first time with object orientated programming in php and I can't figure out how to access elements or methods when you place objects inside objects inside other objects. my origonal idea was to use the following syntax: $a-b-c but this just returns: $a-b . -c Please, need advice on the finer points of OOP in PHP -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] PHP OOP
[snip]I'm working for the first time with object orientated programming in php and I can't figure out how to access elements or methods when you place objects inside objects inside other objects. my origonal idea was to use the following syntax: $a-b-c but this just returns: $a-b . -c Please, need advice on the finer points of OOP in PHP [/snip] Here is a link to an article that helped get me started on oop in php http://www.phpbuilder.com/columns/luis2420.php3 Daniel -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP OOP
On Tue, 30 Sep 2003 19:00:18 -0400 Geoff Hellstrand [EMAIL PROTECTED] wrote: I'm working for the first time with object orientated programming in php and I can't figure out how to access elements or methods when you place objects inside objects inside other objects. my origonal idea was to use the following syntax: $a-b-c but this just returns: $a-b . -c Please, need advice on the finer points of OOP in PHP $a-$b-$c-method(); -- Raquel We must learn to live together as brothers or perish together as fools. --Martin Luther King, Jr. -- Raquel We must learn to live together as brothers or perish together as fools. --Martin Luther King, Jr. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP OOP
Hi, Wednesday, October 1, 2003, 9:00:18 AM, you wrote: GH I'm working for the first time with object orientated programming in php and GH I can't figure out how to access elements or methods when you place objects GH inside objects inside other objects. GH my origonal idea was to use the following syntax: $a-b-c GH but this just returns: $a-b . -c GH Please, need advice on the finer points of OOP in PHP if you have this class a { var $var_a = 'A'; function a ($var){ $this-$var_a = $var; } function get_var(){ return $this-var_a; } } class b { var $a = ''; function b ($var){ $this-$a = new a($var); } function get_var(){ return $this-a-get_var(); } } $class_b = new b(Hello'); You can access class a directly with $class_a_var = $class_b-a-var_a; but this relies on you knowing the structure of your classes. (note we drop the $ after the -) What is better is to use the black box method and make access functions in each class and do $class_a_var = $class_b-get_var(); This way we can change how class a works and not worry about how it stores its data. With this method if we change the variable name in class a to $new_a the code will still work, where as $class_b-a-var_a will now fall in a heap. Hope this helps -- regards, Tom -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP OOP x Procedural Performance
At 04:05 29.05.2003, William N. Zanatta said: [snip] It is a known issue that function calls are expensive for the processor. The OOP let us better organize the code but, thinking in function (or method) calls it may be more expensive than in the procedural form. My question is, has anyone made any tests regarding the performance of OOP versus procedural language? Is it a good choice to code in OOP with PHP ? [snip] Recently we did some research for a decision on how to proceed with a project - basically the question was should we use objects for tata storage, or simple associative arrays and a static class handling array nodes. The testbed source is copied below. The test was run on RH Linux 7.2 running on a Dell Rackmount Server with 2x1GHz, 1GB memory, Apache 1.3.27, PHP 4.3.2. The numbers: 3.912186 secs (0.039122 msecs each): Created 10 array entries 0.397721 secs (0.003977 msecs each): Write-Accessed 10 array values 0.364761 secs (0.003648 msecs each): Read-Accessed 10 array values 0.343353 secs (0.003434 msecs each): Deleted 10 array values using store[idx] = null 0.302970 secs (0.003030 msecs each): Deleted 10 array values using unset(store[idx]) - 4.880921 secs (0.048809 msecs each): Created 10 object entries 0.492642 secs (0.004926 msecs each): Write-Accessed 10 object values using direct access 1.148577 secs (0.011486 msecs each): Write-Accessed 10 object values using access method 0.465929 secs (0.004659 msecs each): Read-Accessed 10 object values using direct access 0.977031 secs (0.009770 msecs each): Read-Accessed 10 object values using access method 0.490641 secs (0.004906 msecs each): Deleted 10 object values using store[idx] = null 0.298719 secs (0.002987 msecs each): Deleted 10 object values using unset(store[idx]) Comparing the numbers (Array = 100%): Creating: 124.7% Write-Access (direct): 123.8% Write-Access (method): 314.9% Read-Access (direct): 127.7% Read-Access (method): 267.9% Deletion (set to null): 142.9% Deletion (using unset): 98.5% For a small number of objects the performance penalty may be minimal. However if you're dealing with a huge number of instances it may be worth considering different approaches. One interesting thing to note is that clearing an array entry using $array[$idx] = null; is between 20% - 40% slower than using unset($array[$idx]); function measure($start = null, $string = null, $passes = null) { $x = microtime(); if ($start) { list($s0, $s1) = explode(' ', $start); list($e0, $e1) = explode(' ', $x); $time = ($e0 + $e1) - ($s0 + $s1); if ($passes) $x = sprintf(%f secs (%f msecs each): %s\n, $time, ($time * 1000) / $passes, $string); else $x = sprintf(%f secs: %s\n, $time, $string); } return $x; } function make_array() { $a = array( 'rid' = null, 'owid' = null, 'pid' = null, 'dcid' = null, 'dsid' = null, 'drid' = null, 'usg' = null, 'rtb' = null, 'idx' = null, 'env' = null, 'xid' = null, 'ci'= null, 'cr'= null, 'cd'= null, 'cts' = null, 'cs'= null, 'ctx' = null, 'cbl' = null, ); return $a; } class TEST { var $a; function TEST() { $this-a = make_array(); } function access($entry) { return $this-a[$entry]; } function set($entry, $value) { $this-a[$entry] = $value; } } function runtest($cmd, $text) { global $LOOPS; global $astore; global $ostore; $code = EOC \$x = measure(); for (\$i = 0; \$i \$LOOPS; ++\$i) $cmd; echo measure(\$x, $text); EOC; eval($code); } function arcopy($x) { $a = array(); while (list($k, $v) = each ($x)) $a[$k] = $v; return $a; } $LOOPS = 10; $astore = array(); $ostore = array(); runtest('$astore[] = make_array()', 'Created $i array entries'); runtest('$astore[$i][rid] = $i', 'Write-Accessed $i array values'); runtest('$n = $astore[$i][rid]', 'Read-Accessed $i array values'); $astore2 = arcopy($astore); runtest('$astore[$i] = null', 'Deleted $i array values using store[idx] = null'); $astore = $astore2; runtest('unset($astore[$i])', 'Deleted $i array values using unset(store[idx])'); echo -\n; runtest('$ostore[] = new TEST()', 'Created $i object entries');
[PHP] PHP OOP x Procedural Performance - Conclusions
First of all. Thanks everybody for the feedback. It was very precious to hear from you. So, there's no big differences unless we're working with heavy processes. Even in this case, the performance seems to be very good in both practices, thus I'll keep OOP. My OOP concepts are not really sharp yet but I'm learning more and more everyday and I feel very satisfied with that. I still get caught in some aspects of classes abstraction, probably due to the lack of design. I see OOP fitting in all contexts I've got until now, at least due to code organization. Also, I like that thoughts of using it primarily for Core libraries (I have my own 'class Core' too) which drives much of my system. But I'm wondering about that discussion on 'outputs'. I don't see any reasons why don't do that, we can have an abstract class and other classes implementing 'drivers' for the needed formats and that would fit really good in some environments where data are output in many formats. Thank you all guys!!! Regards, William N. Zanatta -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP OOP x Procedural Performance
It is a known issue that function calls are expensive for the processor. The OOP let us better organize the code but, thinking in function (or method) calls it may be more expensive than in the procedural form. My question is, has anyone made any tests regarding the performance of OOP versus procedural language? Is it a good choice to code in OOP with PHP ? -=[ William N. Zanatta ]==[ [EMAIL PROTECTED] ]=- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP OOP x Procedural Performance
yes, the bottom line is code reuse...that is why there is oop. So that a developer can always reuse code saving money on development and thus if speed is an issue then adding more hardware. -- Ray On Wed, 2003-05-28 at 20:05, William N. Zanatta wrote: It is a known issue that function calls are expensive for the processor. The OOP let us better organize the code but, thinking in function (or method) calls it may be more expensive than in the procedural form. My question is, has anyone made any tests regarding the performance of OOP versus procedural language? Is it a good choice to code in OOP with PHP ? -=[ William N. Zanatta ]==[ [EMAIL PROTECTED] ]=- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] PHP OOP x Procedural Performance
[snip] It is a known issue that function calls are expensive for the processor. The OOP let us better organize the code but, thinking in function (or method) calls it may be more expensive than in the procedural form. My question is, has anyone made any tests regarding the performance of OOP versus procedural language? Is it a good choice to code in OOP with PHP ? [/snip] We have done some informal testing and have found negligible difference mostly due to current processor power, even on single processor machines. Therefore OOP in PHP is a good thing when used correctly. HTH! Jay -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP OOP design question
I have several web projects that are all database driven. I have recently been diving into OOP, and rewriting a lot of procedural code in OOP. I have a design question about handling the MySQL connection. I have a mysql() class which handles all my queries, automatic inserts/updates, etc. Just about every other class will use the mysql() class at some point. Should I 1) Make every class extend mysql(), so that they all have direct access to the db functions 2) Create a new mysql object inside of each class. 3) Only create the mysql object at the script level, and pass in the object to the other classes. I.e.: // Create the db object $mysql = new mysql(); Now create whatever other objects I need, passing in mysql as an argument. $job = new job($mysql); 4) Some other idea? Thanks for any help, Joseph -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP OOP design question
At 14:24 04.03.2003, Joseph Szobody spoke out and said: [snip] I have several web projects that are all database driven. I have recently been diving into OOP, and rewriting a lot of procedural code in OOP. I have a design question about handling the MySQL connection. I have a mysql() class which handles all my queries, automatic inserts/updates, etc. Just about every other class will use the mysql() class at some point. Should I 1) Make every class extend mysql(), so that they all have direct access to the db functions I wouldn't do that. First of all this would counterfeit the OOP goodies of encapsulating the actual implementation, i.e. your MySQL class wouldn't be the transparent blöackbox it ought to be. 2) Create a new mysql object inside of each class. That's a better way but you need to manage the database connection to avoid repeated reconnects... only way if to make it class static. 3) Only create the mysql object at the script level, and pass in the object to the other classes. This would be my choice and is exactly what I'm doing, not only for database objects but for all other objects I'm using. This is my approach: I have a centralized object storage. No global variables, only a couple of public functions. For example, the function (note: not a method) pos_getobject returns a reference (!) to any object. If it doesn't exist it will be created. The syntax is: $hObj = pos_getobject($id); where $id is the object ID. This ID could be either a constant (e.g. OBJID_DATABASE), or an ID referencing a database-persistent object. In my case, object ID's that are negative numbers are predefined objects (e.g. OBJID_DATABASE), positive numbers are DB persistent objects (simply the row-ID where the object header can be retrieved), and non-numeric IDs are temporary objects that may be created at runtime. If you don't need to take such a general approach I'd create a public function to retrieve the database object: $hDB = pos_getDB($dbid); where $dbid is a database identifier in case you need it. Just my 2c, -- O Ernest E. Vogelsinger (\) ICQ #13394035 ^ http://www.vogelsinger.at/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP OOP
I have a problem, I can't create an array of classes into a class, for example: class one { var $a; function foo() { echo foo; } } class two { var $b; function initialize() { $b[0] = new one(); $b[1] = new one(); } } $test = new two(); $test-initialize(); $test-b[0]-foo(); //It doesn't work $test-b[1]-foo(); //It doesn't work Any suggestion? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP OOP list
Is there a newsgroup list for PHP and OOP? It would be great to split up this large topic and create an OOP specific list. InsaneCoder -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] PHP OOP list
Try http://www.phpclasses.org; Warren Vail Tools, Metrics Quality Processes (415) 667-7814 Pager (877) 774-9891 215 Fremont 02-658 -Original Message- From: Mathieu Dumoulin [mailto:[EMAIL PROTECTED]] Sent: Tuesday, July 23, 2002 10:36 AM To: [EMAIL PROTECTED] Subject: [PHP] PHP OOP list Is there a newsgroup list for PHP and OOP? It would be great to split up this large topic and create an OOP specific list. InsaneCoder -- 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
[PHP] PHP OOP: Multiple Class Extends
Attention PHP guru's, I have a question about PHP and OOP. My problem is that I want multiple inheritance functionality in PHP but it does not support this (see http://www.zend.com/manual/keyword.extends.php). My question is can PHP classes be extended multiple times to simulate multiple inheritance? Is this supported? Is this safe? It do seems to work. ? class A { var $A = A; } class B extends A { var $B = B; } class C extends B { var $C = C; } $test = new C(); var_dump($test); ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] PHP OOP: Multiple Class Extends
Extending more that once, as you did in your example, is perfectly okay. It's just when you try to do it in one go. ie. you can't do multi-extends, but you can extend more than once (if you get what I mean) HTH Martin -Original Message- From: Nathan Cassano [mailto:[EMAIL PROTECTED]] Sent: Friday, March 22, 2002 9:49 AM To: [EMAIL PROTECTED] Subject: [PHP] PHP OOP: Multiple Class Extends Attention PHP guru's, I have a question about PHP and OOP. My problem is that I want multiple inheritance functionality in PHP but it does not support this (see http://www.zend.com/manual/keyword.extends.php). My question is can PHP classes be extended multiple times to simulate multiple inheritance? Is this supported? Is this safe? It do seems to work. ? class A { var $A = A; } class B extends A { var $B = B; } class C extends B { var $C = C; } $test = new C(); var_dump($test); ? -- 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
[PHP] PHP oop in C
Hello, Does anyone know how to take a PHP class and move it directly into PHP's C code, OR (even better) to move it into C code that compiles in a separate binary object (e.g. myobj.o), and is then linked to the php executable (or httpd executable)? For example, how can I move this code into C? ? class myObject { function myObject { $this-data = "hello!"; } function hello () { echo $this-data; } } ? Thanks! -Matt -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]