PHP 5.3 Released 120
Sudheer writes "The PHP development team is proud to announce the immediate release of PHP 5.3.0. This release is a major improvement in the 5.X series, which includes a large number of new features and bug fixes. Some of the key new features include: namespaces, late static binding, closures, optional garbage collection for cyclic references, new extensions (like ext/phar, ext/intl and ext/fileinfo), over 140 bug fixes and much more."
Hooray fileinfo is standard! (Score:1, Flamebait)
Now I don't have to do a song and dance of ugly hacks to get what I need from a file on systems without the extention.
Oh wait, almost any PHP project eventually gets reduced to a song and dance of ugly hacks.
Re: (Score:2, Funny)
Oh wait, almost any PHP project eventually gets reduced to a song and dance of ugly hacks.
*sigh* Yes, yes, we know, and Python or insert-your-pet-language-here is a gloriously clean and not-at-all counterintuitive* wonderland of fantasy and enchantment where fairies and elves smile upon you and give you their blessings and unicorns piss rainbows and shit candy.
At least until the next hip, trendy language comes out. How's your Ruby on Rails coding coming along?
*: Obviously, because if anyone finds it counterintuitive and an ugly hack, they are wrong and ugly and stupid and smell funny so there.
Re: (Score:2, Troll)
Re:Hooray fileinfo is standard! (Score:4, Insightful)
__construct() is a magic method, just like __get(), __set(), __destruct(), __isset(), __toString(), so on and so forth. Magic methods are called without the programmer having to call them, under specific circumstances. In the case of __construct(), it's called when an object is instantiated. '__' defines a magic method and was chosen back in the day because PHP didn't have protected/private members and so the common practice was to prefix private/protected members with one underscore.
PHP was a solution to Perl, so -> is what Perl uses so that's what PHP uses.
The function naming is not so much an issue either. But what is frustrating is argument order. That's something that really needs to be revamped, backwards compatibility be damned.
Re: (Score:2, Informative)
Assuming your argument-order frustration lies with the classic needle/haystack inconsistency throughout the string and array functions, the whole issue goes away if the PHP guys would simply evolve the string and array natives to be treated like objects:
in_array($needle, $haystack) -> $array->contains($needle)
strpos($haystack, $needle) -> $string->pos($needle)
etc.
Do that, and people will naturally migrate from the old inconsistent methods and move towards the more natural and consistent new meth
Re: (Score:2)
Well actually that's what the SPL extension aims to achieve.
http://ca.php.net/manual/en/intro.spl-types.php [php.net]
If you want a stronger typed language, this is your solution.
Re: (Score:3, Insightful)
In seriousness, I'm with the OP. I wish the ridiculous language evangelism would stop. In the end, people are just being short si
Re: (Score:3, Interesting)
Re: (Score:2)
Version 1 & 2 of PHP was a Perl library and was originally named "Personal Home Page Form Processor". That's the original source of the sigil in front of the vars ( and the name "PHP" and a lot of other holdovers ). Version 3 was converted to C.
Re: (Score:3, Interesting)
Thank you, you got the gist of my post.
Every language has its strengths, weaknesses, glaringly awful bits, shiningly wonderful bits, and all of the subculture that go with those things. No language is perfect or even acceptable for every job.
PHP is an extremely organic language. It is the result of hundreds of developers' efforts and the inclusion of many modules that were once addons.
I've been using it since very early version 3.0, so I know why things are named the way they are. That doesn't make them
Re: (Score:2)
Re: (Score:3, Funny)
slash-achievements!
Achievement unlocked: [ Post 5 consecutive posts using the Preview button first ]
Re: (Score:2)
Having used PHP along with a whole slew of other languages, what I've generally found is that like most other languages PHP is a bit of a slave to its own history.
For PHP, its origins in dynamic web pages lead it towards results which are quick and often convenient for web designers who are great at making sites pretty, but lacking in design consistency and rigor. Some effects of this are APIs with inconsistent naming and structure compared to other languages, and the prevalence of bad code practices among
Re: (Score:2)
For Python, it's emphasis on simple syntax means that it's very hard to determine the capabilities of an object just by looking at the code that uses it. Choose bad variable names and you'll be in real trouble.
What the hell does this mean?
Re: (Score:2)
Here's an example:
def foo(bar):
myVar = bar.baz()
Quick, what methods are available to be called on myVar? Answer: you have no idea, unless you know what bar is, and what bar.baz() returns.
Don't get me wrong, I like a lot about Python (and actually it's currently my primary language on the job), but it does have some downsides.
Re: (Score:2, Offtopic)
PHP as I told a manager is useful because it is ubiquitous, not because it is perfect or even particularly good. At the time I worked on a derivative of GForge, which is a definite example of the horrors that can come from PHP projects.
This is also an original quote by me: "The beauty of PHP is that it is so simple even an idiot can program with it. The problem with PHP is that so many idiots do choose to program in it."
In my own hosting, I have the choice of using RoR, but the app must be manually redeploy
Re: (Score:2)
5.3 should be cool, now I just need to start pestering my hosting providers about upgrading.
Dude, dedicated server!
I also always pick PHP because its so nice to code with it and because of the box it provides so many different functions from many areas. It saves you lots of time and work if you dont need to always write your own functions for everything or google for a library. This is also why I prefer Delphi over C++.
Re: (Score:2)
Pfffft!
Everything changed with the release of Drupal (written in PHP).
We are creating several large projects each year based on Drupal/PHP and our solutions easily bests any proprietary solutions I've encountered so far.
Missing Feature. (Score:1)
You forgot the most important change of all.
They added support for "goto".
Re: (Score:1)
It doesn't make the code less debug-able at all.
features! (Score:2, Informative)
PHP now comes with more GOTO!
Re:features! (Score:5, Funny)
Re: (Score:2)
hahaha, thanks for that! I can't believe they put that in the official manual. Too awesome
Re: (Score:2)
The PHP documentation maintainers just got a +1, Awesome in my book.
Re: (Score:3, Insightful)
Re: (Score:1)
Agreed on the GOTO, but as you say, "critical mission error handling may take advantage of a more direct way to 'jump'". Yet, what is 'structured exception handling' like
try:
do this
and that
except:
do the other thing
finally:
this
but a syntactic sugar for an "ON ERROR GOTO" like in BASIC?
Re:features! (Score:4, Insightful)
Anyway, exceptions in languages like Java which enforces its treatment in compile time are more than just a "goto error handling". It all depends on the language you are using.
Re: (Score:2)
Like tail calls instead of gotos? ;-)
Re:features! (Score:4, Funny)
Re: (Score:2)
Re: (Score:2)
Where ever you go, there you are.
Re: (Score:2)
Re: (Score:3, Insightful)
I don't think that's quite fair. I think if the functions, calling conventions and naming were regularized, it would be a reasonably decent scripting language. But it's because it suffers multiple personality disorder that it's a horrendous pain.
Re:Would you let it die already? (Score:5, Insightful)
I think if the functions, calling conventions and naming were regularized
...and they removed the sigils, and removed the silent type coercion, and eliminated the "@" function prefix, and removed the "global" keyword, and removed the weird "list" lvalue function that looks-like-functional-pattern-matching-but-really-just-cosmetically, and fixed the pass-by-reference semantic...
But if you did all of these things, it really wouldn't be PHP anymore.
Re: (Score:2)
You forgot ... create a "terminator" to send back in time and eliminate the millions of moronic PHP hackers who have already created a legacy of horrendous PHP code that the world is now stuck with like radioactive waste from a dirty nuclear bomb.
Honestly, modern PHP used in a correct manner is tolerable ... but the legacy will never go away and nor will the millions of infected PHP coders who will continue to perpetrate the sins of that legacy into the future. Keeping those people out is actually the num
It's true! (Score:2)
Years of php programming have danaged my bain to!
Looking Forward To It (Score:5, Insightful)
I truly appreciate the hard work of the PHP development team and the free language they have given us, congratulations on the new release.
Re: (Score:1, Troll)
It's also slow as shit, has bad/no real professional support, and looks even worse than PHP.
Ruby tards are even worse than Python tards.
Re: (Score:2)
Re: (Score:2)
Does Ruby have an equivalent of APC yet? (JRuby doesn't count.)
Re: (Score:2)
Hallelujah on the register_globals. At least magic quotes are now deprecated. Here's looking forward to 6.0 when they are finally removed!! (I've talked to way too many devs who think they are adequate protection against SQL injections)
Re: (Score:2)
So yes, while you can write decent programs in PHP, most good programmers (i.e. the ones who understand the problems) don't want to. Even accounting for good programmers who don't have a choice, you end up with a disproportionate amount of the underskilled in the remainder.
Re: (Score:2, Insightful)
No, no no. PHP is the "new COBOL". It's a horrible language, but it's built up too much inertia to get rid of it or most of its backward-compatibility disasters.
If you want the new VB take a look at Ruby - a language that lets you bring any webserver to its knees in only 5 minutes and 10* lines of code, no experience required.
*plus 800000 lines of framework
Re: (Score:2)
Also, VB WAS slow... to the already mentioned "retards". Most of the "slowness" came from constant string concatenation, using implicit type conversions, bad coding practices when instantiating forms with massive ActiveX baggage, Late Binding, COM/Marshaling Transparency, and about 100000 other things that all are avoided by competent people. Visual
Horray (Score:5, Funny)
Maybe someone can look over my login script and tell me if this will work in PHP5?
$query_login="select * FROM user";
$result_login = mysql_query($query_login) or die("Your passwrod is might be bad I think");
while($row=mysql_fetch_array($result_login))
{
$username=$row["username"];
if ($username==$username1)
{
echo "";
echo "window.location.href='login_error.php?rec=qq';";
echo "";
exit;
}
}
Re: (Score:1, Insightful)
Re: (Score:1)
Re: (Score:2, Funny)
Don't get your hopes up... I've seen real code that's worse.
Re: (Score:2)
Re: (Score:2)
STAY AWAY FROM THE KEYBOARD RIGHT NOW!! That's it, easy, let go... That's all gonna be alright... (Pst! Somebody call 911..)
Re:Horray (Score:5, Funny)
If you can't tell that the parent post is a joke you're probably a PHP programmer.
Re: (Score:2)
LOL... I'm a PHP programmer.
*sigh* Someone a few posts up basically said this: "A language so simple an idiot can us it... so a lot of idiots do.". Sadly, I have to agree. A majority don't know what SQL injection or HTTP Response Splitting is.
Re: (Score:2)
Not all PHP coders are idiots. I code in many different languages that are required of me while I'm at work. But for some reason I just love how easy it is to put something together in PHP when I'm home playing with some hobby code..
Re: (Score:2)
My best feature... (Score:3, Funny)
...is the ability to employ goto, though it is not allowed to jump into a loop or switch statement. A fatal error is issued in such cases.
Re: (Score:3, Funny)
so it's goto, but not as we know it?
Re: (Score:2)
Namespaces...about time! (Score:1)
The lack of namespaces in any programming language is a massive car wreck just waiting to happen. I once spent a few days trying to resolve an issue with a web portal application with different components brought together where the issue was caused entirely by a function name collision.
Re: (Score:1)
Re: (Score:2)
You didn't get a "function already exists" type of error when it was redeclared? Strange.
Re: (Score:2)
the testing server likely had error_reporting set to 0
new features in php 5.3 (Score:2, Informative)
Re:new features in php 5.3 (Score:5, Informative)
You can also read the official release announcement instead of some random guy's blog.
http://php.net/releases/5_3_0.php [php.net]
Re: (Score:2)
Re: (Score:2)
The backslash name separator looks awful to me, although I've always found PHP code kind of garish with all the dollar signs and curly braces. Although it's at least readable compared to some perl I've seen!
Looking at the "what's new" list I see the cool new feature of php archives. .phar files are zips or tarballs that can be included all at once in your program. Seeing that brings up something I've always struggled with in PHP. When should one use "include," "include_once," "require," or "require_once?
Re: (Score:2)
The backslash name separator looks awful to me, although I've always found PHP code kind of garish with all the dollar signs and curly braces. Although it's at least readable compared to some perl I've seen!
Looking at the "what's new" list I see the cool new feature of php archives. .phar files are zips or tarballs that can be included all at once in your program. Seeing that brings up something I've always struggled with in PHP. When should one use "include," "include_once," "require," or "require_once?" Seems like include normally just inserts the included file into the current source code as if it was there to begin with, no? I guess in the past without namespaces that's probably what most people needed most of the time. And after converting my development wholesale to python with it's inherent namespaces (which are really just singleton objects bound to a local name), it seems like PHP's system is a bit convoluted.
In a nicely made OOP application, you should never have to explicitly use require/include and instead use a class autoloader.
Re: (Score:2)
Unfortunately traits did not make it into 5.3.
Which sucks because I thought that was one the coolest new things.
Nuisances (Score:2)
Let's say you've been using PHP since about a month after Rasmus released it 15 years back, so you've got a whole lot of code that uses the ereg family of regex functions. So they've depricated them, and plan to yank them from PHP 6. Why? Is the overhead so terrible? Or do they really think that it will improve our lives if we have to go back through everything and translate eregs to pregs?
Then there's the change in MySQL password formats. Sure, if they include the latest MySQL libraries they have a differe
Re: (Score:2)
There's a huge codebase out there that's using PHP against MySQL, and using PHP's original ereg regex syntax instead of the Perl-wannabe stuff. What are they thinking, when they set out to break this? When 5.3 rolls out through the distros a whole lot of MySQL backends will fail on the password thing. And when 6.0 rolls out millions of regexs will suddenly be failing. Needlessly.
Given the current state of the economy, this is how you can help keep PHP programmers employed... and why you have a test environment where you install new stuff like this before deploying it across your platforms... so you can find all of the pitfalls, traps, changes, etc, without causing your site to fall down and go boom.
Re: (Score:2)
They've been talking about these changes for a long, long time. If you're still using ereg, or register globals, or magic quotes, or whatever else you want to complain about them changing, then that's your problem. If you have important code laying around that you haven't looked through yet, you might want to pencil that in. There's no reason to have PHP4-only code sitting around these days.
Re: (Score:2)
Change is almost always painful and scary but you'll be happy for it in the end. Update the code and be glad they don't stay backwards compatable to every iteration of the language.
It's better to clean up and remove the old stuff and continue improving the language. They don't have enough resources to bugfix and improve such a lengthy/aging codebase.
Re: (Score:3, Insightful)
Uh, no.
Assuming that people running and maintaining the code are paying any attention, when 6.0 rolls out, those installations that have work
Re:Nuisances (Score:4, Informative)
There's a huge codebase out there that's using PHP against MySQL, and using PHP's original ereg regex syntax instead of the Perl-wannabe stuff. What are they thinking, when they set out to break this?
Nothing is broken. Ereg is moved to the 'official' extension pack called PECL, which you can use for full backwards compatibility. At the same time the community has been warning not to use the ereg functions for the past at least 3-4 years, if not more, citing worse performance, worse featureset, and the possibility of PCRE replacing it at some point in the future.
Re: (Score:2)
Is there somewhere that lists all of the functions that are about to be deprecated? I've used ereg several times in the past few months and am going to have to go and replace those now. It would be nice to avoid the extra work in the future.
Re: (Score:1)
Theres a list of functions deprecated in PHP 5.3 [php.net]. I can't find an official list for PHP 6 though.
Re: (Score:2)
me first .. :) (Score:2)
Namespaces (Score:1)
Re: (Score:2)
nt4 (Score:1)
Re: (Score:2)
NT4 is 12 years old at this point. Is this really a surprise?
I mean, its successor (Windows 2000), is already 9 years old!
The main issue with PHP is highlighted here. (Score:2)
Comparison PHP - Java (Score:2, Troll)
Some time ago I *had* to work with PHP. I haven't known it before that. Now I hate it =). At that time I wrote a comparison, out of anger about PHP being so much used. This is the comparison Java - PHP I have wrote [reloco.com.ar].
Re: (Score:2, Insightful)
Re: (Score:2)
In my experience, in a modern server PHP uses more CPU than Java. You might be right about slow machines though. I don't understand why you make such a big deal about servlets vs jsp, as jsp is just a technology to ease the construction of servlets (every jsp gets converted into a servlet)... And I don't agree you can't compare PHP to Java, they try to serve the same purpose.
Re: (Score:1)
In my experience, in a modern server PHP uses more CPU than Java. You might be right about slow machines though. I don't understand why you make such a big deal about servlets vs jsp, as jsp is just a technology to ease the construction of servlets (every jsp gets converted into a servlet)... And I don't agree you can't compare PHP to Java, they try to serve the same purpose.
They serve same purpose, but they both werent invented for the same purpose. Out of the two PHP was designed from the ground up to just serve dynamic webpages, and that is its primary purpose. Java on the other hand is designed as an all purpose language.
A serious question (Score:2)
I've been trying to figure them out since they were announced for 5.3. I think I understand them, but I don't know whey or where you would want to use them.
Re: (Score:1, Informative)
It might be easier to think about them as anonymous functions than as lambdas / closures, though they're both.
They can fit anywhere that used to take a callback. For example, array_walk() and array_map() can be written in a much more sane way, without having to create an external function and refer to it by name.
But PHP is shit! (Score:1)
And now the waiting.. (Score:2)
.. begins! Maybe in another 2 years we'll get this into CentOS/Redhat.
And by the looks of it, we might see PHP 6 around the same time we return to the moon.
(and I choose the space program as a comparison to another endeavor that seems to be progressing at a rediculously slow pace)
Re: (Score:2)
Re: (Score:2)
Looks like that link's slashdotted! IBM? Surely not?!