PHP 5.5.0 Released 219
New submitter irventu writes "The long-awaited PHP 5.5.0 has finally been released, bringing many new features and integrating Zend's recently open-sourced OPcache. With the new Laravel PHP framework winning RoRs and CodeIgnitor converts by the thousands, Google recently announcing support for PHP in its App Engine and the current PHP renaissance is well underway. This is great news for the web's most popular scripting language."
The full list of new features is available at the Change Log, and the source code is at the download page.
PHP 6.0 without the stupid? (Score:5, Insightful)
I'm still waiting for a PHP 6.0 that's an actual rewrite without all the stupid. With every new version, I just see more features get tacked on ("Objects").
It's wonderfully backward compatible because nothing really gets removed in newer versoins, but it would be nice if the language could be made more pleasant to use.
Re:PHP 6.0 without the stupid? (Score:5, Informative)
The thing that bothers me most is the inconsistency in function names or argument order. When I'm using PHP, I have to constantly keep looking the functions up to make sure its doing what I expect.
Re: (Score:2, Redundant)
Oh hellz yeah. Glad I'm not the only one this annoys.
Re:PHP 6.0 without the stupid? (Score:5, Funny)
so do I.. but then, I'm old and I have to do that for everything. Maybe its not the language after all.. just saying :-)
Re:PHP 6.0 without the stupid? (Score:5, Informative)
Re: (Score:2)
so do I.. but then, I'm old and I have to do that for everything. Maybe its not the language after all.. just saying :-)
I'm not old, well, super old, but I've always found that to be a good practice anyway. Too often I'm switching between 4 or 5 languages, all of which do something differently (why the heck can't we have uniform names for routines across langauges?!? Yeah, I know, big dream and horses got out of the barn years ago.)
Re: PHP 6.0 without the stupid? (Score:5, Insightful)
Re: (Score:3)
What I've found to be truly bizarre is that a lot of the official documentation makes no sense, in and of itself. It's vague and difficult to interpret. You normally have to scroll down to the comments to see how people actually use it, and it's only at that point that the function in question begins to make any sense. The documentation itself is just too barebones to be adequate.
Python's practice of including simple examples with the documentation of virtually every command and function and feature is incr
Re: (Score:3)
Re: PHP 6.0 without the stupid? (Score:5, Insightful)
Part of the problem with PHP is that it's designed to be simple to pick up... Many people start by just adding one or two simple PHP tags to an existing HTML file and go from there.
No need to learn a development environment, no need to create archives or packages, quite literally anyone can create their first "dynamic" webpage by adding one line of php to an existing html file, many people do something really simple like just show the current time etc.
This accessibility has a price, because php is accessible to people with little or no experience of writing code, then lots of such people use it and this often results in very poor code. It's perfectly possible to write very clean code with PHP, you just have to look for it amongst all the thousands of novice programmers turning out junk.
Re: (Score:2)
Re: (Score:3, Insightful)
Hey, don't blame all of us for Wordpress.
Re: PHP 6.0 without the stupid? (Score:5, Informative)
Ha. As a programmer in at least two handfuls of languages over 40 years from IBM 1130 ASM, FORTRAN, ALGOL 68, Pascal, Basic (ick), APL, etc., and long time programmer in PHP, I am presently in the process of hacking up someone else's Perl.
Nobody who writes in Perl can have anything to say about the structure, style or consistency of PHP. PHP may have grown like topsy and it could certainly use some revision of function argument order, but it at least uses a syntax that is remotely similar to other common imperative languages - java, c, etc. From my first look at Perl in 1995 I always thought Perl looked like sneezing, and now I'm working with it, my first impression was correct. (Although in fairness I use PCRE in PHP quite a lot!)
This is my most recent 'fave' quote from perlsyn - on 'when', which is part of Perl's attempt to rethink (or something) the switch/case pattern [perl.org]:
Exactly what the EXPR argument to when does is hard to describe precisely, but in general, it tries to guess what you want done. Sometimes it is interpreted as $_ ~~ EXPR, and sometimes it does not. It also behaves differently when lexically enclosed by a given block than it does when dynamically enclosed by a foreach loop. The rules are far too difficult to understand to be described here. See Experimental Details on given and when later on.
Pathologically Eclectic Rubbish Lister [perl.org] indeed!
Since I'm on a role here, I will complain about one thing in Python, though I've only programmed a bit in Python. Python's much vaunted 'indent' based nesting is a mistake, because it only uses one invisible marker (which may be instantiated by several symbols - spaces and tabs, at least) to do this. All other common languages I can think of use different markers for begin and end, which acts as a kind of 'double entry bookkeeping' for the parser. Without a closing marker, Python's parser has no way to catch errors in leading spaces.
A similar type of error results from C's syntax, which was unfortunately adopted in PHP - in allowing action inside a conditional "if ($foo = 1 + $bar)", the poor parser has no way to know if one really means 'compare' or 'assign'. This is the cause of innumerable bugs in both languages. This could be fixed by requiring assignments inside a conditional to be surrounded by block markers: "if ({$foo = 1 + $bar})".
But I like all 'scripted' languages better for my purposes (entirely applications, no device drivers or kernel work) than C and other 2nd generation languages. I've had exactly one segfault working with PHP, in nearly 20 years.
Re: (Score:2)
A similar type of error results from C's syntax, which was unfortunately adopted in PHP - in allowing action inside a conditional "if ($foo = 1 + $bar)", the poor parser has no way to know if one really means 'compare' or 'assign'.
I don't understand. I'm not a parser, but to my eye that means "assign." If you wanted to compare, you would do "if ($foo == 1 + $bar)", no?
Re: (Score:2)
A similar type of error results from C's syntax, which was unfortunately adopted in PHP - in allowing action inside a conditional "if ($foo = 1 + $bar)", the poor parser has no way to know if one really means 'compare' or 'assign'.
I don't understand. I'm not a parser, but to my eye that means "assign." If you wanted to compare, you would do "if ($foo == 1 + $bar)", no?
Ah, but in C, and thereby in several other languages that have adopted C syntax, the result of the assignment becomes the value of the conditional, so "if ($foo=1+$bar)" means, 'add one to $bar, assign it to $foo, then evaluate the conditional based on the value of $foo'. Maybe that's what I meant to write, but maybe I just mistyped. So thus arises an ambiguity - did we mean assign and then evaluate, or just compare? And thus bugs are born. It is quite easy to accidentally put '=' when we mean '=='. Bu
Re: (Score:2)
Cool. I haven't written significant C in 10 years, so wasn't aware that gcc did that. Although IMHO it would be semantically better to use {} instead of () as the inside symbols, since {} identifies blocks elsewhere.
Will it ever become part of standard C?
Re: (Score:2)
Re: (Score:2)
Scope by indentation. How retarded is that?
You haven't played with TCL, have you?
Re: (Score:3)
Yeah no kidding. Another big gripe of mine is how most of the things that you'd like to try/catch doesn't throw an exception, but some sort of "notice" or "warning", which you cannot respond to. I've managed to work around this by implementing custom error handlers, but that brings its own problems when other peoples' code expects the default behavior. What's worse is the stuff that throws warnings/notices are things that are very basic: accessing an array element that doesn't exist, opening a file without
Re: (Score:2)
I don't want to disable error reporting. I want to respond to errors and not get stuck writing a bunch of garbage if statements just to see if every condition I can think of is covered before accessing a file or an item in an array. It's not that I "don't care about my variables/arrays", it's that I would appreciate them behing handled properly.
In Python, I can do (sort of, can't format correctly here):
try:
f = open('/path/to/file', 'r')
except IOError, e:
# Oh no, I can't do that... handle accordingl
Re: (Score:2)
Re: (Score:2)
Re: (Score:2)
is_null and isset for example. I hate these functions. From what I understand someone thought it was a good idea to copy some C function names, which I think just makes the inconsistency worse.
Re: (Score:2)
Comment removed (Score:5, Funny)
Re:PHP 6.0 without the stupid? (Score:5, Informative)
== and === are common in dynamically typed languages
assert 1 == true //works //works // fails // fails
assert 0 == false
assert 1 === true
assert 0 === false
Re:PHP 6.0 without the stupid? (Score:5, Insightful)
Indeed, but the problem is type coercion and not dynamic typing. You can have a dynamically typed language that does not coerce unlike types to make life "easier".
Re: (Score:2)
No, it's not. Dynamic typing let's you save a lot of time because when you use one of those languages there is rarely need to explicitly state the type of a variable and everything keeps working just fine. Furthermore, thinking of Ruby, if you try to mix different types without an explicit coercion it reminds you that you are doing a mistake and kills your program. I don't know why but it never happened in production. Only in development mode. It's tests, which one should do anyway, or just that we don't mi
Comment removed (Score:5, Insightful)
Re: (Score:2)
assert("hello" == 0); will succeed, but
assert("1" == 0); and assert("1hello" == 0); will fail.
Starting to see a pattern here?
Re: (Score:3)
Re: (Score:2)
Re: (Score:2)
Re: (Score:2)
It's a language designed for the web. When you submit a form, everything is a string (or a file), there are no ints or floats. So, the language has to work around this issue, and being loose-typed, and having two comparison operators that work they way they do, is part of what makes PHP easy to use for the web.
Cheers.
Re: (Score:2)
Re: (Score:2)
assert(""==false);
assert(0==false);
assert("0"==false);
assert(null==false);
When a form is submitted, there is no bare 0, there is only "0", so PHP treating "0" as if it where 0 in certain cases is certainly understandable. It may not be obvious or intuitive to you, but there is certainly a good reason for it.
See also: PHP type comparison tables [php.net]
A comment on that page says:
Hardly complicated.
Re: (Score:2)
Re: (Score:2)
"Hardly complicated."
s/Hardly/It's/
Re: (Score:2)
Honestly I find == good enough for normal usage in PHP. Javascript is another matter.
Re: (Score:2)
Re: (Score:2)
strpos and friends are one of a few exceptions, to which developers are prominently alerted in the documentation.
Re: (Score:2)
They could've just gone with -1 as a return value and had no problems; it's not like PHP stops you from doing substr($foo, false)—in fact, it casts false to 0 and returns the whole string.
But that's just the thing: there are so many documentation-requiring exceptions of various kinds that you can't program without keeping the documentation open. I've written pretty large applications in PHP (including a full interpreter for a scripting language) and there's a true paucity of consistency. No other lang
Re: (Score:2)
Re: (Score:2)
Re: (Score:3)
I can’t even say what’s wrong with PHP, because— okay. Imagine you have uh, a toolbox. A set of tools. Looks okay, standard stuff in there. You pull out a screwdriver, and you see it’s one of those weird tri-headed things. Okay, well, that’s not very useful to you, but you guess it comes in handy sometimes. You pull out the hammer, but to your dismay, it has the claw part on both sides. Still serviceable though, I mean, you can hit nails with the middle of the head holding it sideways.
Re:PHP 6.0 without the stupid? (Score:5, Insightful)
Because then some people would have to stop updating? The place I work has code dating back 10 or 11 years and the programmers already have to go through the code each update to see what got dropped and even then there will be demands for the upgrade to be rolled back or "delayed" (moved to a point in the future that never happens because they never have time for it).
It's not just in house stuff that doesn't update either, Check out large Open source projects and see how many of them generate warnings related to deprecated functions.
If you want a language that has no cruft there are languages you can switch to but not many people use them for the reasons stated a above.
Re: (Score:2)
Cruft is there for a reason. [joelonsoftware.com]
What the computer does is complicated. We use the written high level language to generate the instructions that the computer actually executes to "do something." The instructions are what "do something." Someone might stare in puzzlement at why some seemingly irrelevant value is bit-shifted right 8 bits. No reference in the code to it. BUT
Re: (Score:2)
I'm still waiting for a PHP 6.0 that's an actual rewrite without all the stupid.
Here you are (just run on shell):
/dev/null
tar cvfz php-6.0.0-stupidless.tar --files-from
You're welcome.
Re: (Score:2)
Perl had a good sized install base and a healthy community, and then they tried this with Perl 6.0. Can't imagine it would go any better for PHP.
Re: (Score:2, Interesting)
And I'm still waiting for all the PHP haters to fork it and create a new version and "do it right." The language is open source, you know.
Evidently none of the self-proclaimed "experts" in programming language design is willing to fix PHP.
Re: (Score:2)
Re: (Score:3)
I read the Laravel page and it's great to see how closely they managed to mimic Ruby and Rails (I used "and" on purpose). However it also exposes the limits of the language.
This PHP
$tasks = User::find(1)->tasks;
$author = Task::find(5)->user()->username;
$task = new Task([ title: 'Go to store.' ]);
User::find(1)->tasks()->insert($task);
would be this Ruby
tasks = User.find(1).tasks
author = Task.find(5).user.username
task = new Task({title: 'Go to store.'}) # but the {} are idiomatically remove
Re: (Score:2, Funny)
That would be Perl.
Bugs & Maintainers (Score:5, Informative)
It's no fun having to keep our own custom patchsets for PHP just to keep it running properly.
Re: (Score:2)
Re:Bugs & Maintainers (Score:5, Funny)
Fork it?
Shame on you for harming future generations of girl coders! I must tweet your picture and publicly shame you!!!!
Citation needed (Score:5, Insightful)
With the new Laravel PHP framework winning RoRs and CodeIgnitor converts by the thousands
Citation needed. Why does the summary contain this blurb which is not even relevant to the story. Me suspects that the submitter could be an advocate who just ceased on an opportunity to tell slashdot about his favorite PHP framework.
Re: (Score:3)
just ceased on an opportunity
I don't think that means what you think it means.
Re: (Score:3)
No, he wanted to say "seized". But I blame Noah Webster: Before he came along, people spelled words any way they dam wel pleezed.
Not even trying to be statically safe (Score:4, Interesting)
You only need a peek to see this Laravel dubbed "PHP renaissance" does not even try to be statically safe. It's littered with pitfalls like writing your validators with strings, such as: "array('name' => array('required', 'min:5')), ...".
(It is possible to write statically typed validators, with clean syntax (depending on language) and you end up not loosing stuff like auto-completion, semantic checking by IDE etc. See for instance latest Scala PlayFramework and it's JSON validation, it is relatively easy to use, and syntax is surprisingly succinct taken the fact it's extremely type-safe.)
PHP renaisaunce (Score:2, Offtopic)
Re: (Score:2)
Re: (Score:2)
Really? (Score:5, Insightful)
With the new Laravel PHP framework winning RoRs and CodeIgnitor converts by the thousands
Citation please.
Re: (Score:2, Interesting)
Yeah, I'd like a citation, too. I'm a RoR developer and had never heard of Laravel. Looking at the syntax in the Laravel quick-start brings back bad memories, though. PHP just isn't very good at DSLs.
Re: (Score:2, Funny)
I'm a RoR developer
And you admit this publicly?
Re: (Score:2)
Citation please.
"With self-discipline most anything is possible." ~ Theodore Roosevelt
*ducks*
Re:Really? (Score:5, Funny)
Okay. How's this? [wikimedia.org]
Re: (Score:2)
Damn, I wish I had mod points. That was good for a chuckle. Thanks.
Re: (Score:2)
Gordon H. Bennet, it looks like someone took Garth's car from Waynes World, cut it behind the doors, found another one and cut it in front of the doors, and then welded the bits with doors together.
Comment removed (Score:4, Interesting)
Re: (Score:2)
$x = $source->indexOf($needle);
and
$x = $source->replaceAll($needle, $regularExpression);
?
Yeah, I'm sure (Score:5, Insightful)
CodeIgnitor? Maybe. RoR? Um, no. Or, perhaps, in your dreams.
As an RoR developer who left PHP years ago I assure you - we aren't just waiting for a really good PHP framework that's an RoR knockoff. Part of the greatness of Rails is Ruby, and looking through the Laravel docs just confirms that. It looks like Laravel is about as nice as you can get on PHP, but ultimately it's still PHP underneath (and on top).
Rails is a meta-language built on top of Ruby. Just can't do that in PHP.
And that's not even getting into the ugliness of PHP's cruft that's been built up over the years.
Re: (Score:3)
There are RoR developers left? Seriously? I've not heard much about RoR after the $500k I made circa 2009/2010 coming in and cleaning up the mess on a few projects. Ironically enough it often involved rewriting projects mostly in PHP, but others in C# or Java, and even sometimes even with Perl. Granted most of the problem was non-developers reading how RoR does all this stuff automagically for them, they don't have to think or know, and turning out a blog in 15 minutes some how makes them a "developer"
A public thank you to the PHP team (Score:5, Insightful)
Yes it has its flaws, yes you sometimes don't know whether you're looking for needles in haystacks or haystacks in needles, but it's not like they're not aware of that, and it's not really a big deal either in these days of syntax and function aware editors and instant online reference, and it has provided me and i'm sure many thousands of other people with a career not just in contract coding but also in being used almost exclusively on our own websites.
Thanks guys!
Guilty pleasures (Score:5, Interesting)
I dream about getting away from PHP and occasionally dip my toes in other waters (Python, Java, and even C++) but always come back to PHP. I won't go to Ruby for as many websites start with Ruby and then abandon it for many other languages. People blah blah about MVC but often what I am doing is just too damn simple to need such added complexity. I might need a program that I occasionally run to view a list of spam flagged submissions; it is done in 10 minutes in PHP. I don't use any frameworks and am diligent enough to keep things running through prepared statements and whatnot. With opcode caching and memory caching of data PHP is very very fast.
It is not so much that PHP is the best at anything it is that it isn't really terrible at anything I care about. Almost every other language is terrible at at least one thing that I do care about.
Personally I think that PHP gets its bad rap because it is a very easy transition from HTML. So you have basically non programmers starting to sprinkle PHP into their HTML and oddly enough an untrained programmer's first efforts end up being crap. Then because PHP covers all the web server basics these programmers potentially never venture beyond PHP and there is nothing better for making a bad programmer than a one language programmer. (Not someone who primarily programs in one language but one who only ever learned the one language) So these same programmers keep expanding the scope of their terrible code.
So if anyone can suggest a programming language to replace PHP I would love to know (and all JVM languages are off my list).
Re:Guilty pleasures (Score:5, Informative)
There are a lot of very real technical reasons why people don't like PHP. The syntax and naming of its function library is inconsistent, the type coercion is irregular, and it's inconsistent about warnings vs. errors—it tends to keep executing code even when it shouldn't, potentially leading to unwanted behaviour during development if a variable isn't set or something. Reddit has a fairly active board devoted to the various problems [reddit.com] that can occur, not all of them avoidable.
One of the most peculiar details in all of this is that PHP's original author (and, I think, but don't quote me on this, a portion of the development staff) considers himself a non-programmer; that PHP was just thrown together to simplify work. That would be okay, but it's led to a lot of security holes, bugs, and irreversible bad choices over the years, like having to use === in string parsing because false is returned by strpos() if it doesn't find anything (and false == 0). No other language requires this particular quirk.
I don't blame you for not liking Ruby. While it's a much cleaner language, it's got some very peculiar syntactical features that make a lot of people scratch their heads—most notably, there are circumstances under which return doesn't work normally [stackoverflow.com], which can be very frustrating. However, there are some very creative uses of familiar syntax that, for example, make strings really easy to work with; haystack['needle'] = 'thread' is the same as $haystack = str_replace('needle', 'thread', $haystack) in PHP. I haven't used it personally, but I think the major reason Ruby projects get abandoned so much is because the people writing code in it are not experienced programmers.
Running down the list a little and hopping over JVM stuff, the other decent web languages you may want to consider are Perl and Python. Both have extremely well-developed libraries and are good with strings, so it's mostly just a question of picking "esoteric and terse" vs. "newbie-friendly and easily maintained." Decent JVM languages include JWT, Scala, and Clojure (with noir [chris-granger.com]; check out that sexy beast), although JWT is probably overkill for anything smaller than Gmail.
Re: (Score:2)
I just replied elsewhere about my recent experience with Perl - Perl makes PHP look like a paragon of consistency and well-designed code. But I do like Perl regular expressions - as implemented in PHP! :D
Python's use of a single, invisible marker for blocks - the indent - is a mistake that causes a lot of bugs. Blocks need different begin and end markers to allow the parser to know what goes where.
Re: (Score:2)
Return works fine; trying to return from something that isn't a method doesn't. The most striking thing about this question is that the submitter never explains what they are doing or why they insist on doing it in a non-idiomatic way. "I'd really prefer to be able to use 'return' in this scenario" is not a compelling argument. What reason did he have for trying to work around a reasonable, well established language paradigm?
As far as people abandoning Ruby, I'm not sure it is more or less common than ot
Re: (Score:2)
Oh and str_replace has fooled me many times so I now use preg_replace. Little harder but much cooler.
Re: (Score:3)
I like your link to a page containig a picture of a hammer with a claw on both ends.
I raise you a link to a page describing a pentagonal room. PHP: a fractal of bad design.
http://me.veekun.com/blog/2012/04/09/php-a-fractal-of-bad-design/ [veekun.com]
I cant believe nobody has linked to that blog posting yet. It's a classic.
Re: (Score:2)
"it tends to keep executing code even when it shouldn't" and exit unexpectedly when you do not want it to.
You could not make a language handle exceptions any worse than PHP.
Re: (Score:3)
Actually I'm in the same boat. PHP works fine for all the little things I do and even a few big things. I've tried poking at Ruby a little and wasn't interested enough to pursue it. While I've done C programming in the past (80's and 90's), and perl (90's and 00's), most of my more recent work is scripting in general; shell scripting, some perl stuff, and loads of PHP+MySQL+JavaScript.
I have asked the same question in past PHP rant threads but with no response.
[John]
Re: (Score:2)
People blah blah about MVC
My company has been using the MVC framework CakePHP for quite a few projects over the last few years. It never seems to get any public attention, but it works really well for us and has a lot of nice features.
Re: (Score:2)
Re: (Score:2)
Re: (Score:2)
I love Perl for its regular expression use. It is so incredibly easy to do so many things after you realise how easy Perl makes RE use. I also think how it handles classes is cute, if not all that usable. But the rest of the language is pretty much crap.
PHP is quite nice, but does a bunch of stuff a little off and is quite general at everything,
If it's a connection method, it's the real deal (Score:2)
escape_string_no_we_mean_it_this_time_why_are_you_laughing_v2
My rule of thumb is that if the escape function is a method of a database connection object, such as the $conn->escape_string() of MySQLi, it's the real deal. But most of the time, I just use prepared statements, reserving manual escaping for things like the right side of operator IN [pineight.com] that would need a large, variable number of placeholders.
Hosting plan compatibility (Score:2)
Why drive nails with a screwdriver when you could use a hammer instead?
Because hosting plans, especially budget shared hosting plans, are more likely to come with a screwdriver than with the particular version of a hammer that your application needs. You could have the best web app in the world written in Perl or Python, but you'll pay more to run it than you might on PHP-only hosting. MySQL is popular for the same reason: ubiquity on entry-level hosting.
Re: Hosting plan compatibility (Score:2)
"the web's most popular scripting language"?!? (Score:2)
Given that I've seen exactly zero PHP programs running as scripts outside of a webserver environment, I'm calling bullshit on the idea of PHP being a scripting language, let alone "the web's most popular" one.
Re: (Score:2)
Actually phpunit runs scripts from the command line but yes, usually they are tests for code that eventually runs in a webserver. Anyway a large and well done PHP project has much more code in models, controllers and libraries that in HTML views so it's not easy to say that it's just a templating language.
About being the most popular, it probably is. It's either it or Java or some .NET language. Python and Ruby are following at a distance. Given all the free or cheap PHP hosting servers my bet are on PHP. B
Great, even more versions of php I cannot use. (Score:2)
Being stuck developing on other peoples servers.
One thing I found very strange was how much it matters. It is surprising how many necessary, basic features have just been added.
Re: (Score:3)
Yes, why NOT rewrite the entire language tokenizer for vague reasons of potentially avoiding a single keystroke?
Re: (Score:2)
Re: (Score:2)
The CPython folks constantly moan about parser complexity, and even they managed it.
Re: (Score:2)
Yah, they were really great in BASIC!
Re: (Score:2)
if token.type == TOKEN_TYPE_STRING {
if keywords.contains( token.value ) {
handle_keyword(token);
} else {
handle_variable(token);
}
}
Re: (Score:2)
Re: (Score:2)