Introduction to PHP5
Yet Another OO Fanatic writes "PHP core developer Sterling Hughes has a excellent presentation (mirror) about PHP5 online. So far it seems to be the best coverage of the new features in PHP5; highlights include the new object model, namespaces, interfaces, access control and exceptions. Java by any other name..."
0 posts, and already slashdotted? the subscribers must've gotten to that one early!
And what's with the java comment, PHP is pretty much nothing like java. It has different uses, different strengths, and different semmantics. When are they going to properly fix PHP like making it stable? (*gasp*)
just came out too. a decent combination of better features. My only wish: that there was an easier way to do subselects. I knwo almost every one uses the php+mysql+apache combination when doing stuff on linux. I also know that many others like me are really pissd off about the whole subselects thing. I for one have written my own functions to do similar things in php. I knowmany others who have as well. Im sure php developers could produce a standard way of doing it and make it faster.. oh well
The war with islam is a war on the beast
The war on terror is a war for peace
"This is what I get for running a server on pre-alpha software."
Well that, and having your website posted on slashdot. Of course it'll crash. Sorry, I'd RTFA if I could get to it...
Sometimes I doubt your commitment to Sparkle Motion.
True, true.. Why is no one coming up with real new features in programming languages? It's been a long time since there was anything truely innovative. We're essentially still using constructs that were dreamnt up for computers that had 1k RAM 1 KIPS back in the 60's. Surely with the available processing power we have today, we should be able to make languages far more expressive, easier and safer.
And next is a PHP-based J2EE compliant application server.
No, it's running PHP5. That's the problem. Still very very alpha.
And, if you want it right now, instead of waiting for PHP5, go get Ruby today. It's got all of this, and many more neat features. I've recently been moving PHP over to Ruby, because PHP wouldn't scale to a large project (taking 4-5 seconds to load and generate a page on a hefty server, the codebase was only about a meg and a half of PHP), and because it was incessantly segfaulting for mysterious reasons. I've had no such problems since.
And ruby's a lot of fun... you can use it for tiny scripts, sites, or large projects.
Don't think of it as a flame---it's more like an argument that does 3d6 fire damage
michael should just not post commentary to the stories that he posts, php is definately java by any other name.
"this [the talk] is hosted on NYPHP's servers... and is running Apache 1.3.27 + PHP5. PHP5 leaks worse than the Titanic..."
And you linked to it from Slashdot and expected it to survive long enough so that any non-subscriber could click on it?!
Java has a static type system (compile-time type declarations). PHP5 presumably still has a purely dynamic type system (but the site isn't responding...).
Hopefully... PHP5 will either address some of the common mistakes (without becoming brainless) or at least have some good example out there.
If anyone has noticed... one of the major areas of death/slashdotting of sites apart from bandwidth are php URL's... and/or mySQL queries (often on PHP URL's). I've not yet noticed many Perl-run pages that have been slashdotted so successfully as PHP.
Now, I'm not sure if that's a faultof PHP itself, or that some of the "easier" features of PHP tend to attract less competent programmers and/or misconfigurations?
I'm actually OFFENDED that you would compare PHP5 to Java. I don't want to start rambling off the difference (though I will mention EJB and taglibs, just to put something in the hat).
I'd rather ask the submitter if he'd like to truely argue why he thinks this new version of PHP is just like java.
Good quote, too many chars. Seriously, the slashdot 120 char limit sucks!
Java by any other name...
/me dawns the flamesuit.
Leave it to a Perl guy to compare PHP to Java.
features in PHP5; highlights include the new object model, namespaces, interfaces, access control and exceptions.
Of course, Perl has had all this for some time.
Just curious, how can you have an object model without namespaces? Or interfaces for that matter? Isn't that like "New Car - with tires!"??
Either way, PHP makes for a good interface language for web apps - I guess. You can throw it on top of an application layer to do the real work. Last I checked, you could only use SOAP to do this - has anyone tested how well that performs? SOAP doesn't scale all that well.
It would be nice to let the HTML monkeys handle some of this stuff while the serious development can take place in a real language.
Does anyone know if this version will have better support for suexec-style permissions handling without using php as a perl module script thing? If I'm unclear, what I mean is will php commands like chown and chmod actually be functional on files not owned by the user apache runs as, based on the user who owns the site/scripts?
[sig]www.masterslate.org[/sig]
Ok...I know about LAMP. This is fine in the "web" community. What do /.'ers think of JOLA (Java Oracle Linux Apache) for the corporate environment.
:)
Before the flames start, I have talked to a quite a few IT managers and they are very reluctant to try open source. Since Oracle and Java are mature, why not toss in only two open source solutions (Linux and Apache). Ease it in slowly. Then, when they don't expect it, hit them with mySQL or PostgreSQL and then PHP
Comments?
Link doesn't seem to work.
Suggest you paste this into your browser's address bar.
http://talks.php.net/show/php5intro
PHP Accelerator is really quite good, and is free. It compiles the code once, and then caches that for each load.
Either most slashdot readers are now actually reading the articles
... Anticipatory Slashdotting.
It's a new feature of PHP5
NO CARRIER
Wait. You don't have to pay extra for tires? =)
I'm still trying to figure out why I had to pay extra for floor mats.
If I had something intelligent to say, I would have said it.
Slashdot authors need to get a clue. Don't link to an obviously quoted pre-alpha server.
PHP 4 and previous versions taught most of us that if you run it even a 13-year-old script-kiddy can 0wn your site. New version, new features aside, PHP can't catch on much more than it has until more of the holes in it's implementation are patched. Would any of us buy a fancy car without locks? PHP is much the same, really nice to use but without security is it worth it?
I tried to RTFA, and all I got was this lousy error message.
If slashdot mirrored pages that people want to see, then we might end up slashdotting slashdot. I only load up the page once and then link to all the articles. If you think that one article is approximately the same size as slashdot (possibly bigger if it has screenshots), and I do 4 click throughs per slashdot session. If you can assume that each user would require 5 times more bandwidth... then even slashdot might have a problem.
--------- I have no signature
From the blog :
PHP5 isn't ready
This is what I get for running a server on pre-alpha software.
Ok, so as many of you already know, I have my talk for NYPHP online. This talk is hosted on NYPHP's servers, and is running Apache 1.3.27 + PHP5.
PHP5 leaks worse than the titantic. With MaxRequestsPerChild at 100, apache children grew to 37MB (before we stopped counting). At MaxRequestsPerChild at 40, it was around 27mb. Finally, we've settled on a reasonable default 25 requests per child. MaxClients at 50.
This is a box that can easily handle 20 times this load. ugh.
PHP5 is pre-alpha. Don't think otherwise.
I know that zope is great for dynamic content. Is the new PHP better?
i'll begin doing some php only when microsoft will have released Visual MSPHP. Thats it.
http://talks.php.net/show/php5intro
Not trying to karma-whore, I just thought I'd use my +1 for something good because nobody seemed to notice the AC link.
The requested URL
This slashdotting is getting a little out of hand. Why doesn't slashdot actually start making articles out of these news items instead of links to other sites where no one can read the news.
Can you say "statistically insignificant"?
"I'd rather be a lightning rod than a seismometer." -Ken Kesey
Did Slashdot just attempt an upgrade to PHP 5?
There is no reasonable defense against an idiot with an agenda
:wq
Internal Server Error
Apache/1.3.26 Server at slashdot.org Port 80
1 - Better variable scoping features. I'd like to be able to say something like...
where 'session' is a keyword that executes a block of code or variable declarations in session scope, and have those variables persist throughout the session. Same for application scope, that is variables in that scope persist for the entire life of the PHP engine, and available in all scripts. ( was that the ACLs they were refering to? in the story summary? )2 - Built in Opcode caching.
3 - More consistant library function naming.
4 - Support for 'taglibs'. The same functionality can be done using functions, well sort of. But this is very usefull when separating the work between web programmers and non-technical designers/maintainers.
That's my list...
But yeah, you're right, I should shut-up and code them or stop complaining.
Based on upvotes, Ageism is the only "-ism" Slashdotters care about and think isn't SJW
In PHP, all you have are scripts. Sure they may be optimized, compiled, pseudo-object-oriented and even obfuscated... but they are still scripts. They may even include eachother. But they are still *SCRIPTS*.
/.'d are simply bad coding. Making 16 database accesses per page is not bad when just a few people visit at once, but when the stampede comes, your toast. Most people don't develop with that in mind.
After executing, they forget all knowledge. There is no persistence, no threading, no transactional support. All attempts to improve efficiency are afterthoughts and hacks.
At one point I tried to implement in-memory "application" wide shared data. The concept is, something may need to be loaded when the site is first loaded, and then it should be kept in RAM, and we need exactly ONE instance of it.
I gave up... using shared memory was too tricky and isn't even platform independent. It's not part of the core language, and even if it worked, it would not turn PHP into an application. It still runs in a modular fashion.
Now with a Java servlet, you have an application that is running. Within your servlet you may define some data exist indepently of web requests. Servicing a request is just one aspect of it. Its much more like a real program, which is why it're referred to as an Application Server.
For very simple things, that don't need to scale, both in usage, and codebase, then PHP is ok. But for design real web applications, which need to be managed by more than a few developers, integrate with legacy systems, implement a full three tier architecure, etc, PHP just doesn't cut it.
A lot of the bad sites which go down easily when
Java has some serious strengths in the Web department, it's proven technology, and is not very complicated at all. It's just that most people aren't used to writing structured code. JAva forces you to follow somewhat good practices and the extra work pays off in maintainability. PHP and Perl you can just hack away, without any strong typing, etc and get something done very quickly but in the end it will become a mess quite fast.
I'm not saying Java will solve your problems, but there is a strong base of best practices, design patterns and example code to help you keep your code in nice shape.
With PHP, it seems like everyone has their own code libraries, utility scripts, ways of coding, etc and its really tough to resuse someone elses code. Java Interfaces and Inheritence comes in very handy.
Ok... enough ranting. Anyway, I used to be a hardcore PHP supported because you could whip together things very easy, but as I learned more java and needed to do larger projects and learned more about efficient coding, I realized with PHP you will eventually just run into a wall and that's when it's time to look for better solutions.
A drop in share in one month doesn't conclude to the OS dying. However, you bring up an interetsing point. When Apache loses ground, it never gets posted to Slashdot. When Apache gains, no matter how slight, it does get posted.
I'm all for the promotion of open source, and certainly Apache is a kickass product.
There is no reasonable defense against an idiot with an agenda
:wq
I was at a talk on JBoss, and they were saying there a "killer App" would be a PHP interpreter to run PHP inside JBoss so you could get things like real transaction and failover support...
"There is more worth loving than we have strength to love." - Brian Jay Stanley
Java by any other name...
What's this Java you speak of? Oh! Yes, I think I will have a cup; two sugars, no milk, please.
Spread the RC luvin'
The parent of this comment is a redirect to goatse.cx.
Just a word of warning! 8')
> Leave it to a Perl guy to compare PHP to Java.
Leave it to a Java guy to make asinine comments about practitioners of another langauge. Leave it to a C++ programmer (me) to compound the error.
> Of course, Perl has had all this for some time.
Yah, so have lots of languages. That makes it entering PHP no less exciting.
> Either way, PHP makes for a good interface
> language for web apps - I guess. You can throw
> it on top of an application layer to do the
> real work.
My, how casually dismissive. PHP scales far better than Perl does. Go talk to the yahoos at Yahoo!. (There are good arguments raging about PHP vs. Java in scalability, and so I won't start that here, as I don't want a bad argument to be my fault. Go read if you want to, but don't just assume that because you can't write scalable PHP it can't be done.)
StoneCypher is Full of BS
I that PHP might possibly be the only web scripting toolbox on earth worse than ASP, and it gets marked as flamebait. I suppose it deserves it -- ASP is amazingly ugly. Comparing anything to ASP is pretty damned hostile.
But, lets be frank here. PHP really amazingly shitty.
Slashdot is jumping the shark. I'm just driving the boat.
PHP? What's that? If you can't write it in pure assembly, its not worth writing!
>> Just curious, how can you have an object model without namespaces?
My understanding is this is more of a syntax thing - PHP4 effectively has namespaces in that you can place functions in a class (namespace) so that's 1 level deep. With PHP5 you can nest classes within a namespace block so you've got a further "layer" where outside of which names won't conflict. Believe their also introducing nested classes, which amount to the same thing.
The interfaces thing is a step towards Java (along with abstract classes). With PHP4 you have inheritance (extends keyword) and you can use it as you will.
Course the presentation is asking to be flamed by Perl coders after some unnecessary anti Perl remarks...
Great... now I have to upgrade all my servers... Weeee! Oh well, maybe the have some new session stuff.
-------
"In times of universal deceit, telling the truth becomes a revolutionary act."
-- George Orwell
I'm guessing you bought either a German car or an Italian car ...
run PHP as a CGI and not an Apache Module and all your security fears melt away in the night
There are places where the networks are not touching,and there are places where they are-Boeing's Lori Gunter
C'mon if it can be done with GD, and the curl library, surely mcrypt is worth adding.
Have you read the Moderator Guidelines yet?
PHP does scale far better than plain Perl for cgi. But it comes nowhere near Perl when you are using mod_perl, I think our own /. is an attest to that.
Why don't you use a real application server for your persistent objects?
Wasn't it kind of difficult to reinvent the wheel?
> But it comes nowhere near Perl when you are /. is an attest
> using mod_perl, I think our own
> to that.
You think incorrectly, sahib. Even using mod_perl, PHP scales far better. Nice try, though.
The fact of the matter is that with enough attention, most languages scale acceptably. Slashdot runs on a pretty serious server set. I bet you could get a pretty good intercal server going if you tried hard enough.
StoneCypher is Full of BS
... don't you mean "dons"
/me dawns the inane spell checker suit
Zope = Huge bloated Python CMS
Midgard = Huge bloated PHP CMS
Hammer of Truth
Yeah! Sounds like you're still sore about PHP being the first open source technology to come from behind and whoop the incumbent MS equivalent: http://newsforge.com/article.pl?sid=02/06/11/01124 3&mode=thread&tid=5
MSN is up to 9.0 i think, i'll use them to make my new homepage.
MARIJUANA, SHROOMS, X: ONLINE?! - E
mod_perl, postgres, apache and HTML::Mason rock.
My company will develop in anything for cash, but it has been my experience that this combination is hands down the best general purpose web development setup. Rock solid, fast, extremely full featured, great rapid development, and generally fun to write.
I forget what 8 was for.
What I would really love to see is a unified database API. It's horrible to have different APIs for each database.
... have you ever tried to make run odbc with mysql in a 100% unix enviroment ?
I know php has odbc support, but
Java has JDBC, perl has DBI, Microsoft has ODBC... I am waiting PHP can get something like that !
"We all know Linux is great...it does infinite loops in 5 seconds." -- Linus
(here's the pdf) ... many of the changes made bear a striking resemblance to the Java way of doing things Which is hardly a "flame," as one poster accused the article submitter; Java is (still) one of the cleanest language designs around, and gets a LOT of things right.
What I can get to anyway through the slashdotting.
/rant
I managed to get to the namespace page, which I feel is one of the biggest problems, and it says nothing about namespace issues other than 'fixing the object model' and changing OP codes so you can add your own (what do OP codes have to do with it?).
And what does fixing the object model mean? Are they going to create a standard set of classes and move the core functions into them (one can only hope) or are they going to stick with the every_function_in_my_namespace model that drive competent programmers nuts!
I would also love to see them embed regular expressions in the same way perl does. Nothing makes me more annoyed than preg_match() and preg_replace().
The Anti-Blog
Eh? 1 == 100%. And if you are using version numbers, 5 + 100% of 5 is 10.
:)
You prolly mean 20% better. 5 + 20% of 5 = 6
-
ping -f 255.255.255.255 # if only
I'll second your post and take the flames with you:
LONG LIVE PERL!!!
The Anti-Blog
PHP is more and more oriented toward expert coders, giving them more and more OO stuff. That trend is, i think, terribly wrong. Php didnt get its success from expert coders, but from novices one, not knowing ANYTHING about oo. There is ton of stuff to do, and really more interesting stuff. For example : a true translation system to develop multi-language sites, an abstraction layer for SQL (no not a 50k external .php you have to include), to make all functions working on all OS (for example flock() dont work on Windows, even if its not so much work to reimplement it on this system) and so on.
So there is ton of features that could make PHP a true killer, so why working on expert-only stuff ?
- MrNop
To that I say:0 000001 11001100100000011011100110111101110100001000000110 10010110111000100000011011010110000101100011011010 00011010010110111001100101001000000110001101101111 01100100011001010010110000100000011010010111010001 10000001110011001000000110111001101111011101000010 00000111000001110010011011110110011101110010011000 01011011010110110101101001011011100110011100101110 001000000101100101100101011000010110100000101110
0100100101100110001000000110100101110100011
(Score: -1, Stupid)
A minor quibble with an otherwise wise post:
>> A drop in share in one month doesn't conclude to the OS dying
Apache is an application, not an OS. Apache runs on quite a few OS's, and runs on Win32, as a matter of fact.
Everything I've ever learned the hard way was based on a statistically invalid sample.
PHP is a language. ZOPE is an application (mainly written in Python).
Try eZ publish: http://developer.ez.no for a PHP based alternative to ZOPE
This isn't my experience at all.
I've scaled mod_perl to several million pageviews/day levels of traffic - it always behaves predictibly and sanely.
We run php internally, becuase some of the software we use in house is written in it, and all those tools are dog slow.
I don't like php very much, so I don't use it, so I can't compare myself.
Can you point to any real comparisons?
I know Yahoo decided they liked it, but I've never seen real comparisons.
I forget what 8 was for.
No! Apache is an OS as in operating system and it is dying. What is your problem? Why do you have to confuse people? jerk.
My, how casually dismissive. PHP scales far better than Perl does. Go talk to the yahoos at Yahoo!
I personally don't care what the yahoos at Yahoo! think until they show me some benchmarks.
More accuratly their programming staff probably complained that "Perl is too hard" (I hear it from PHP developers all the time). Besides if I understand correctly Yahoo was using CGI (which may have been perl but could have been C or something else)
Scalability depends on a lot more than just the language, it (obviously) depends on hardware and then on how well the app is written. Perl and PHP both will slow a site to a grind if there is inefficient code. (same goes for security to all the people who blab on and on about PHP being inherently more secure)
Finally show me a benchmark! I've only ever seen one un-biased benchmark on this subject (and I can't find it now) and it shows Perl and PHP's scalability to be relatively the same.
The Anti-Blog
Depends on your needs. If you are looking for business class hosting, Command Prompt does well. They have private instance databases instead of shared instance like most other providers.
Is there any talk of separation of code and content? Love 'em, or hate 'em, MSFT has done this with ASP.NET. It seems like a logical progression to the current model, where the content is independent of the code in the implementation behind it. PHP.Net would be very cool, and a nice alternative to C# or VBScript.
See: pear.php.net
http://tinyurl.com/4ny52
How do you disable weak SSLv3 & TSLv1 ciphers on a IIS 5.0 server?
Uhh, yeah, read into their tests. Even after pulling old Rasmus into yahoo, Mod_perl *still* outperformed PHP, even by just at little after all that.
They chose PHP over mod_perl, because it was easier to hire cheap monkeys to bang away on the php pages. They didnt' want all the flexibility mod_perl offered, they needed to give a simple toolkit to bust out pages within their criteria. PHP was the best minimized solution for their needs.
It wasn't the fastest, it wasnt' the most full-featured.
If PHP were so horrible, why is it the most popular module for Apache?
Because all those web "programmers" out there can't be bothered with some of the strictness of mod_perl?
The Anti-Blog
The next step is to make a program for compiling php to byte code so it will be java.
Checking out my form of escapism.
- No paramatarized queries in the standard MySQL database module
- No equivilant to Server.MapPath (read the documentation -- $_SERVER["PATH_TRANSLATED"] doesn't do the same thing)
- The NAME="var[]" thing is a fucking hilarious hack. Every time I read that part of the PHP manual I simply can't stop giggling
- No URL handling functions at all.
- since PHP includes no functions to translate relative URL's to absolute URL's, manually setting headers like your example is an incredible pain in the ass. How would you write the equivilant to <% Response.Redirect("foo.asp"); Response.End() %> in PHP? Remember, you have to send a fully-qualified URL in your response.
PHP is a perfectly fine language if you have a smart, dedicated team writing the custom, application specific extensions in a real language, and simply use PHP as a glue between your HTML and the "real" code. But trying to actually write your "real" code in PHP is a recipe for a hideous, convoluted mess.PHP is simply not a good language for writing web-based applications. It's that simple.
Slashdot is jumping the shark. I'm just driving the boat.
otherwise you will always have a bit of uneeded bloat and "possible" reference inefficiency.
System-wide objects are VERY easy to implement in PHP currently. Just use shared memory and sems....
...) are able to access this data to provide a global data-exchange. Remember, that shared memory is NOT safe against simultaneous access. Use semaphores for synchronization. "
For more information please see: http://www.php.net/manual/en/ref.sem.php
"This module provides wrappers for the System V IPC family of functions. It includes semaphores, shared memory and inter-process messaging (IPC).
Semaphores may be used to provide exclusive access to resources on the current machine, or to limit the number of processes that may simultaneously use a resource.
This module provides also shared memory functions using System V shared memory. Shared memory may be used to provide access to global variables. Different httpd-daemons and even other programs (such as Perl, C,
Please note that: "No external libraries are needed to build this extension."
Ever need an online dictionary?
System-wide objects are VERY easy to implement in PHP currently. Just use shared memory and sems....
...) are able to access this data to provide a global data-exchange. Remember, that shared memory is NOT safe against simultaneous access. Use semaphores for synchronization. "
For more information please see: http://www.php.net/manual/en/ref.sem.php
"This module provides wrappers for the System V IPC family of functions. It includes semaphores, shared memory and inter-process messaging (IPC).
Semaphores may be used to provide exclusive access to resources on the current machine, or to limit the number of processes that may simultaneously use a resource.
This module provides also shared memory functions using System V shared memory. Shared memory may be used to provide access to global variables. Different httpd-daemons and even other programs (such as Perl, C,
Please note that: "No external libraries are needed to build this extension."
Ever need an online dictionary?
Just curious, how can you have an object model without namespaces? Or interfaces for that matter? Isn't that like "New Car - with tires!"??
Plenty of OO languages do not have namespaces. It isn't vital to an object system in the least. They are handy, but far from neccesary.
Last I checked, you could only use SOAP to do this - has anyone tested how well that performs?
Last you checked, you could only do what with SOAP? RPC calls? from PHP to anything else? There are plenty of ways to do something analogous to SOAP, homebrew and pre-built, text (like SOAP or XML-RPC) or binary based.
(not that it matters, but you are donning the flamesuite, not "dawning" it.)
Working toward a usable PDA environment in the spirit of Newton OS: Dynapad
I wouldn't call C++, C for dummies as I find in large scale operations that C begins to look like a scripting language... meaning that it gets out of hand quickly in managing the dynamic set of logical components, data and connections. I like both and bastardize them whenever I can to get the best performance but then maybe my issue is with bad programming regardless of the language.
On the other hand, if in writing even the core in a single language you are then free to avoid JNI crap (or anything else) then yes I can see the benefit. This is why .NET is another example of something that is such a great idea... but is being implemented in a very nasty way.
okay so not impervious to attack, I never suggested that
... may exploit this vulnerability to gain access to any file readable by the user under which the webserver runs.
--
Impact
Anyone
--
with SUEXEC that would be each website owner and it's group so www:$USER
security minded people will already have locked down files outside the webspace to be unreadable by www that leaves the $USER's files.
We use postgres and it's access is via current username rather than password so no passwords would be revealed.
Arbitrary php execution would enable manipulating the DB data and open the door to other nasties [such as privilege escalation via forked shells & other vulnerabilities]
In the end, though, you have to blame the existence of a Super-User model. It's the biggest hole there is.
There are places where the networks are not touching,and there are places where they are-Boeing's Lori Gunter
i don't miss these. reasons:
1. parametarization is not the duty of the mysql extension, but of functions/classes calling it.
2. i think Server.MapPath hasn't been implemented in php since the differences between physical and virtual path are far more complex with apache as a hosting environment (i don't know how Server.MapPath should react on some URL-Rewriting-rules or when used in an 404-Error-page). but if you design you environment sane, providing a function that maps between files and urls is cake in php.
3. i don't find this counter-intuitive.
4. implement them *in* php, don't let your scripting environment put you in a niche. be creative.
5 i feel repeating and do so: design the (file-system-)layout of your scripts well and mapping between them can be accomplished with very simple self-made functions that suit far better than anything embedded in the hoting environment, let it be apache (or another webserver) or php
Do we really have to deal with kludges just to handle backward compatability? Sounds like a good time for a fork. I'd rather have clean syntax.
"God fights on the side with the best artillery." - Napoleon, Marshal of France - speaking truth to power
Of course, Perl has had all this for some time
Perl has an object model? Interfaces? Exceptions? Access control?!?
Except for bless Perl has just as much of an object model as assembly language. Those doing OO in assembly would probably just consider bless to be a convenience function.
I think PHP sucks.
In some sense I agree with you - I have had to spend time supporting a large site written in PHP spaghetti, so I have good reason to hate it. I've also had to deal with similar ASP sites, so I will argue that any difference between the two is insignificant.
But there are applications where I think PHP is fine - places where cost is paramount. PHP is fine for throwaway prototypes, and it offers hosting companies the ability to offer a lot of functionality for a $10 a month site.
So, I'm fuzzy on the whole method overloading thing (I know zilch about PHP, sorry).
If I want to have two methods with the same name (but have different number of args), I have to implement a function called "__call()"? Doesn't that mean that I have to write all the logic for which execution path gets taken based upon the method name and arguments passed into __call()?
Could a PHP expert help me out here, because unless I'm mistaken that looks unbelievably hokey. With Java, I can write two functions ...and the runtime would be able to route calls to the right function. Is this not how PHP works?
>You can throw it on top of an application layer to do the real work.
>Last I checked, you could only use SOAP to do this - has anyone tested how well that performs?
When did you last check, PHP3? PHP has had a Java binding, a Corba binding, and a COM binding for years (since early PHP4). And you can extend PHP with C if you need speed (rather than a more robust OO environment), you can even write your c code inline with php (see Inline_C) for a cool pear package.
The added OO features (and more importantly for speed matters, the fact that objects are now passed by reference and not by value by default) are just going to be a bonus. Exception handling will be nice for large projects.
>Just curious, how can you have an object model without namespaces? Or interfaces for that matter?
The objects in PHP where initially just glorified arrays (like Javascript). However, interfaces and namespaces -- useful as they are -- are certainly not necessary for an object model. You can do very nice OO programming in C if you are disciplined enough. You don't really need the language to hold your hand.
Any code can be written in a spaghetti like fashion including PHP, java, perl, C++, etc...
Conversely code written in any language can also be well documented, structured, and cleanly written. PHP can produce quite functional, stable, robust sites. It just so happens that lots of people get into writing code with php because it's easy to use, and they haven't necessarily had the training or experience to be able to understand good coding practices. It seems to me that lots of the features of php and perl including weak typing that make them easy to use, also provide a good opportunity to create hard to read code. Lots of comments make up for this, as do good variable names, but never knowing for certain what kind of a thing you have in your hands does make code hard(er) to debug, and read when there are problems. The ease of not having to understand typing and type casting does draw a lot of newb programmers to php and perl. And you can pay newb programmers less than expensive computer scientists. It's just a matter of getting what you pay for. A highly experienced php programmer is going to get paid more, and is going to be able to create the high traffic web applications like Yahoo. Just don't expect it from a newb programmer who doesn't understand an array from a vector.
That is, it's exciting when it actually works....
I'm not too sure what kind of system/traffic your site had, but our company runs web-based apps for over 40 insurance agencies across the US.
We have one server that hosts 42,000 lines of PHP code and sees around 1300 insurance agents each day who log in, generate term/ltc quotes and download forms.
Most of the above code drills into a seperate MSSQL database server running Win2k, which actually has become our only bottleneck. That server fails rarely during very high traffic.
Locally the web server also sports a MySQL database server instance which hosts a little under 5 megs worth of rates for Long Term Care quoting.
For Term Life quoting I pull in a 50-200k XML datastream from an outside vendor.
The server hosts 1.7gigs worth of downloadable insurance forms.
All of this runs on a 1Ghz Pentium 3 with a half gig of ram. A good 300 megs of that ram is currently free.
In the three years this has been running I've yet to see php cause a crash in apache.
I'd say it scales pretty damn well.
i've yet to meet somebody intelligent who tried out both mysql and postgresql and then didn't end up moving towards postgresql.
Unfortunately, there are issues with using shared memory that would be better off handled by PHP itself. The integer keys need to be unique, which can be a bit of a pain to generate in the first place, but also lead to issues if other software isn't written correctly and simply uses a hardcoded value. Next thing to you, your data is being screwed with by an unknown app.
/tmp/phppersistant or something, and uses file locking to control access. Of course, you'd need to write it all yourself since I don't know of any existing class to perform this. Even then, nothing comes close to a native solution within PHP itself for speed and reliability. If it's so easy using shared memory, why isn't there already a built in solution using this that is part of the default compile? I'd guess that portability of PHP probably makes this solution useless. Last I checked, SysV IPC wasn't available on Wintel boxes. Sure, the functionality is duplicated within different API calls, but it really isn't SysV IPC.
You'd probably be better off using a file based system that stores data in
Don't want to sound demeaning, but I just don't see the practicality of using shared memory for something that should already be included natively. *shrug*
Just don't expect it from a newb programmer who doesn't understand an array from a vector.
The spaghetti site I ran into was written by an experienced programmer who had just come from an Ada shop. He knew all you said, but the project management was so screwed up that he did not get a chance to apply his skills.
My personal opinion is that most spaghetti sites are not the fault of the programmer, but rather the people managing the project.
The NAME="var[]" thing is a fucking hilarious hack. Every time I read that part of the PHP manual I simply can't stop giggling
And you do this in VBScript how? I worked at an MS shop for awhile and no one there knew how to do this. Not saying it can't be done, but it certainly wasn't intuitive to people working there.
If the syntax for dealing with arrays in a language uses [] as part of the syntax, using
makes perfect sense.
But trying to actually write your "real" code in PHP is a recipe for a hideous, convoluted mess.
Sorry if you think that. We manage to write fully functional apps all the time in PHP which aren't even close to hideous or convoluted.
Remember, you have to send a fully-qualified URL in your response.
IIRC ASP doesn't so this, or at least didn't do this a few years ago. If PHP was *only* written to work with one web server and didn't have to worry about being run in multiple environments, this wouldn't be a problem. As it is, you can feel all smug and safe knowing that you have a command to send a full URL in your response. Whoopee. Many others of us have a very capable and dynamic cross-platform language which is well-suited to writing web-based apps, and we're not tied to a language which was shoehorned into a webserver against its will.
creation science book
While I must admire the PHP developers for going totally overboard and finally adding features to the almost useless class system they had before, I have found that PHP's great strength has been in smaller websites that need simple code. Java has always been overkill in that arena.
.x rellease. The problem with that is that you don't know anymore if your code will "just work" on an unknown server, or if you're going to have to change php.ini and /or your code (if you do it the new way and the server is old it won't work and if you do the old way and the server is new...).
But what has become an increasingly presistant problem is the way that things that are commonly used such as the easy method of automatic variable creation with reg_globals = on, was changed to be default off and similar things that change in every
This, in my opinion is starting to defeat the object of what made PHP so popular in the first place: making a small script easily in an easy language for a small site.
...with so many pages you would do well to spit out more dynamic content, rather than hardwire so many references? Or is that the situation that already exists.
Sorry, I got in the wrong mind track. Too many "BSD is dying" posts screwed up my already messed up brain.
There is no reasonable defense against an idiot with an agenda
:wq
[sung over AC/DC's TNT]
Oi, oi, oi, oi, oi, oi, oi, oi, oi, oi, oi, oi, oi, oi, oi
See me code in the sunset
On my 19" screen
Out for all that I can get
If you know what I mean
mod_perl to the left of me
IIS to the right
Ain't got no shell
Ain't got no life
But don't you start no fight
CHORUS:
'Cause it's PHP, it's dynamite
PHP it'll win the fight
PHP it's a power load
PHP watch it explode
It's dirty, mean and mighty unclean
It's a wanted man
Public enemy number one
Understand
So lock up your server
Lock up your files
Lock up your back door
And run for your life
The code is back in town
Don't you mess it 'round
CHORUS
PHP Oi, oi, oi
PHP Oi, oi, oi
PHP Oi, oi, oi
PHP Oi, oi, oi
PHP Oi
It's dynamite (oi, oi)
PHP Oi,
It'll win the fight,
PHP
It's a power load
PHP
Watch it explode!
frotz grue
There are 5 people helping people groups?
Wow, whodu thought!
lick the cancle button (at least thats what our Chinese QA says)
Comment removed based on user account deletion
PHP 5? I'd settle for a production mod_php 4
that works with Apache 2.
Were that I say, pancakes?
I really hate signatures, but go to my website.
Yeah, that's nice, but I'd rather have PHP handle this stuff for me. If I wanted to mess with shared memory and semaphores, I'd be coding the damn thing in C to begin with.
not all sites need oracle or postgresql, oracle is very resource hefty and expensive. the costs of oracle alone can tank a small business.
plus, mysql is very light. this means it is ideal for embedded systems and PDAs. there's no way anyone is going to shoehorn oracle into a zaurus. mysql runs fine though on it.
postgresql might be more feature-complete, but the community support for mysql is many times better.
advocate oracle and postgresql all you like, it doesnt matter. one size does not fit all.
what is a vector in php? Just curious.
What the hell some people are doing to get these crashes. I've been using PHP for a few years now, and I've never had it seg fault on me, and it runs pretty damned fast (but I do use a compiler). Of course, my sites are pretty small (about nine domains of with about 200 constant users, not including other viewers, on one server), so it could just be happening on the larger servers.
I've been using PHP consistenly for the past four years or so (and Perl for about six years). I'll certainly look at PHP5 once its out of beta, but I must admit that even though the majority of my work over the past three years has been in PHP, all my recent work has been in Python.
A while ago I did a lot of PHP intranet development using custom classes which talked to LDAP data sources, and I came away from my efforts with the feeling that PHP is architecturally inconsistent. Those inconsistencies left a bad taste in my mouth.
I doubt I'll ever stop using Perl, but with only a little direct experience I can already see the day when I will have stopped using PHP in favor of Python.
Visit the site if you want more details on what's good about it. In a nutshell:
- Much easier seperation of presentation and logic
- Easy templating and page filtering
- Excellent but easy component caching (great for those slashdottings
:-)
- It's perl
OK, the last sounds like flamebait, but being perl means you get CPAN, which is a massive boon to any perl coder, no matter the style of development you are participating in.Lastly, if you want to start from scratch, not having experience in either, can I humbly suggest you start with perl rather than PHP. You'll regret having to unlearn all the evil habits you get into once you start travelling the PHP road.
Command attempted to use minibuffer while in minibuffer
Many others of us have a very capable and dynamic cross-platform language which is well-suited to writing web-based apps, and we're not tied to a language which was shoehorned into a webserver against its will.
No, you a poorly written, poorly thought out toy language, shoehorned into a third-rate web framework.
I'm not a huge fan of ASP, but it's a marginally better framework than PHP. Of course, you can write ASP programs in Perl, Javascript, VBScript, and any other language that uses Window's active scripting framework.
I'll gladly admit that nothing else freely available is as simple to get started with as PHP. That's not praise. In my mind, PHP serves as a perfect example of the reasons open-source software simply can not fill every need. A lot of people want a well-thought out, well documented, stable, relatively secure, and very simple to use web framework, similar to ASP. Unfortunately, no competent programmer wants such a thing badly enough to write it. However, a number of incompetent programmers have sat down and scratched their own itch, and come up with PHP.
I'm certain that PHP would make a perfectly useful starting point to write a decent web framework. It really isn't missing that much before it would be useful. But, I've seen no evidence that anyone working on PHP has any interest in writing a decent web framework. And, I've seen no evidence that anyone interested in decent web frameworks is interested in PHP.
Slashdot is jumping the shark. I'm just driving the boat.
I've been working since PHP 3 on a system to transparently store PHP object data in a database and get it out again just as easily. The system, which is set up to be more flexible than your average pseudo-OODB/ CMS (though it's not a full CMS), needs to take heavy use of the PHP object and class metaprogramming functionality. You'll notice when really relying upon it, that the PHP object and class API is a little bit scattered together.
Now they're of course going to rewrite the object system so that it all gets better and easier and more mature, and my code will have to be rewritten from the ground up when I want to support PHP5.
And I thought I was nearly done...
"We can confirm that Debian does *not* ship the version with the trojan horse. Our version predates it." [CA-2002-28]
Just curious, how can you have an object model without namespaces? Or interfaces for that matter? Isn't that like "New Car - with tires!"??
It's more like "Old Volkswagen Beetle - without steering reinforcement and airco, but still running as hell. Yep, they don't make 'em like they used to".
The Smalltalk language, which popped the term "OO" (and the GUI), had neither namespaces nor interfaces. Yet, they've managed quite OK. The language did contain a more complete OO-vision than most languages have today, by making everything an object (it's a little bit more complex than that, but hey), including e.g. if-statements, code blocks, etc.
"Modern" OO languages are almost always a cross-over from C-style syntax and OO-style behavior, which is not really all that disastrous, but sometimes a little bit mind-limiting to people. (For instance, did you realize you can have a full OO language without the concept of classes?)
"We can confirm that Debian does *not* ship the version with the trojan horse. Our version predates it." [CA-2002-28]
For those who can't enter the pages at ny1.php.net, it seems you can get 'em at talks.php.net (counting 34 pages).
Enjoy.
This site describes how you can complie PHP to byte code for a proposed PHP# implementation.
Is it just me? The mirror side gives me on slides 3 updwards:
/local/Web/sites/talks/presentations/slides/php5in tro/except.php on line 3
<?php
define('NUM', 10);
try {
if (NUM throw new Exception(
NUM . " is too small!"
);
}
} catch (Exception $e) {
echo $e->getMessage();
echo "\n
\n";
}
?>
Output
Parse error: parse error in
form other languages I remember different exceptions...
sorry about the 2nd thread, but I figured you wouldn't see this unless I posted this way.
:)
After sleeping on it, I thought of another reason why shared memory doesn't work. Objects that have filehandle references won't correctly persist, since the stream is closed when the php instance shuts down.
A good example of why this is important is dabatase connection pooling. I've worked on a few large commercial websites, written in ASP, backended by Oracle. The system was already existing when I got there, I just helped make a few updates. The interesting part is that the pages were written to share a single database connection that persisted between requests. With a cluster of 25 webservers, and a few million hits a day, it was important to keep the database connections persistant to reduce the connect/disconnect load on Oracle. Instead of having to authenticate over a million connections a day, the Oracle DB was only required to authenticate a webserver on the first request served. The allowed the database to focus on serving out the required data, rather than fussing about opening and closing sockets all day long.
Anyhow, just thought I would bring that up.
My programming knowladge based around PHP. I found it is very nice. It's very easy to learn (that's why I can write web programs. I try perl first. But I found it so confuzzy to understand others programs). Very easy to set it up. That's why its very popular. Also HTML is very easy too. (thats why web is so popular).
Also I found MySQL is very easy to use and maintenance. When you combining PHP/MySQL/Apache, you will found very effective and easy to use web aplication server system.
You may argue, beacuse of asp's bla bla option, beacuse of Java oo capabilities, beacause of Oracle's capabilites. I'm sorry all of them too complicate and and too expensive to create web aplications.
On my side, PHP only lacks one area, Client side. Sending 10k data to clent for each time form loaded making (even using mod_gzip) network load. Also makes entire operation slow.
We just needed, Flash like plugin for browsers.To do some php functions on client. Like graphics, like html. PHP don't need to compare other web technologies. It's much enough to do many things. And we need that god damn client side plugin.
To create, more intereactively web applications. whih are running more faster, can do more thing withouth huge server load and of course escaping javascripts.
Oh of course, there are lots of technologies to do what I we want and I say again, they are too complicated and expensive.
Any PHP God Hear me ?. PHP is fine, of course it can be much better. And we need that client side plugin.
Please consider our, cliend side PHP support. I strongly believe It is open very uncharted areas for PHP.
Thanks
[My english is better than most other people's Turkish, so please point out mistakes politely. Thank you.]
Mod parent up. Should be a separate JWZ +modifier.
Does PHP5 support the mean,evil,threading that would make it even more powerful then 4 currently is? Wonder if they will ever implement threads in it...
Man, PHP5 is looking suspiciously like Java/JSP... so besides the API differences, and the lack of equivalent ability of servlets, i'm wondering where PHP is going... I admit two benefits are "less configuration" and "better memory usage" (although the latter may well not hold with all these OO features being added)...
It's 10 PM. Do you know if you're un-American?
Sigh. Being old and moldy, I have seen more "next great things" flow under the bridge than a lot of the slashdot crowd, and this stuff makes me tired. From the practical standpoint of "getting stuff done", I've come to the conclusion that all infrastructure is equivalent - database/coding language/operating system/etc. What these discussions always end up as is:
- You Have To Check Out 'X', EVERYBODY Is Using It
- (My Preferred System) 'Y' Can Do Everything 'X' Can, AND Can Do 'Z'!
- 'X' Can Do 'Z' Too, You Just Need (Long Kludge)
- So What, 'Q' Could Do 'Z' Back In (Current Date Minus At Least Ten Years)
- My Bad Experience With 'X'
- My Bad Experience With 'Y'
- My Bad Experience With 'Z'
- Long Incomprehensible Story About 'Q' Being Used On A Nuclear Submarine
I have to say that the state of the computer science art has advanced since I went through my schooling, language design and implementation used to be a fairly abstruse topic, and now people knock out parsers at the drop of the hat. What it reminds me of is my experience in embedded systems. At one point, everybody working the field says to himself, "you know, I could write my own embedded OS, this isn't that hard, and I could put in this one feature..." I've whiled away many an hour deciphering some guy's brainchild to extract some tedious bug out of it, when any of four well-known solutions with known stable behavior could have been used instead and avoided the whole exercise.
I'm not knocking people trying to do new things, this is how the art advances. But spare us the "use X (you fools) Y is complete rubbish!" arguments.
and that does not include XML