Modern PHP: New Features and Good Practices 182
Michael Ross writes In recent years, JavaScript has enjoyed a dramatic renaissance as it has been transformed from a browser scripting tool primarily used for special effects and form validation on web pages, to a substantial client-side programming language. Similarly, on the server side, after years as the target of criticism, the PHP computer programming language is seeing a revival, partly due to the addition of new capabilities, such as namespaces, traits, generators, closures, and components, among other improvements. PHP enthusiasts and detractors alike can learn more about these changes from the book Modern PHP: New Features and Good Practices, authored by Josh Lockhart. Keep reading for the rest of Michael's review.
Programmers familiar with the language and its community may recognize the author's name, because he is the creator of PHP The Right Way, a website which he describes as "an easy-to-read, quick reference for PHP popular coding standards, links to authoritative tutorials around the Web and what the contributors consider to be best practices at the present time," in 21 different languages.
Modern PHP: New Features and Good Practices | |
author | Josh Lockhart |
pages | 268 |
publisher | O'Reilly Media |
rating | 8/10 |
reviewer | Michael Ross |
ISBN | 978-1491905012 |
summary | Solid advice on some state-of-the-art PHP tools and techniques. |
Yet rest assured that the book under review is not merely a dead-tree version of the website. Instead, the book covers the more recent advancements within the language, while the website covers best practices and standards. This should be borne in mind, otherwise the reader may be baffled by the absence from the book of certain topics on the website essential to the language, such as SPL, PEAR, and PHPDoc. Moreover, of the topics shared between the book and the website, the information is generally organized quite differently, with more example code in the book.
This title was published on 1 March 2015, under the ISBN 978-1491905012, by O'Reilly Media, who kindly provided me with a review copy. Its material is presented in 268 pages, organized into 13 chapters (The New PHP; Features; Standards; Components; Good Practices; Posting; Provisioning; Tuning; Deployment; Testing; Profiling; HHVM and Hack; Community), which are grouped into three parts (Language Features; Good Practices; Deployment, Testing, and Tuning) — as well as two appendices (Installing PHP; Local Development Environments) and an index. The publisher's page does not offer much of interest. However, all of the example code is available from the book's GitHub repository. There are differences between the GitHub code and what is printed in the book, e.g., a baffling require 'vendor/autoload.php'; in the first example code file. The author claims that the reader does not need to know PHP, but at least "a basic understanding of [] fundamental programming concepts" (page xiv). However, anyone without at least intermediate skills and experience with PHP could conceivably struggle with these more advanced subjects.
The first chapter is only a brief overview of the history of PHP, its current state, and some possible future changes to the language's engine. The real content starts in the second chapter, in which the author gives the reader a fast-paced introduction to his seven favorite major new features in PHP: namespaces, class interfaces, traits, generators, closures, Zend OPcache, and the built-in HTTP server. In some regards, the coverage is a bit too fast-paced, as some topics and questions likely in the reader's mind are not addressed — for instance, namespace case-sensitivity and techniques for ensuring that a chosen namespace is globally unique (page 9). For each topic, its purpose and advantages are explained, and sometimes illustrated with code examples, although none are extensive.
The second part of the book opens with a chapter on some of the new standards in the PHP ecosystem that are intended to move the common development process from a reliance upon one isolated framework, with an idiosyncratic coding style, to distributed components that can interoperate through the use of interfaces, industry-wide coding standards, and the use of autoloaders for finding and loading classes, interfaces, and traits at runtime. Components are covered in more detail in the subsequent chapter, as is Composer, for installing components and managing dependencies. The fifth chapter is a lengthy but information-packed exposition of numerous best practices regarding input data sanitization, password handling, dates and times, and safe database queries, among other topics. Some of the advice can be found in other PHP books and online, but all of this is neatly explained, updated with the newer PHP versions, and worthwhile as a refresher.
Deployment, testing, and tuning are the broad subject areas of the third and final part of the book. The author discusses the options for hosting your PHP applications, as well as provisioning any self-managed web server and tuning a server for optimal performance. All of the instructions assume you are using Linux and nginx, and thus would be of less value to those using Windows or Apache, for instance. The material on application deployment is relatively brief, and focuses on use of the Capistrano tool. Testing is often neglected in real-world projects, but certainly not in this book, as the author explains unit and functional testing, illustrated through the use of PHPUnit. This is followed by information on how to use a development or production profiler to analyze the performance of your application, with detailed coverage of Xdebug and XHProf, among other tools. The next two chapters dive into topics related to the (possible) future of PHP — specifically, Facebook's HHVM PHP interpreter and their Hack derivative language. The final chapter briefly discusses the PHP community. The two appendices explain how to install PHP on Linux or OS X for commandline use, and how to set up a local development environment. The author mentions a free edition of Zend Server, but the vendor page mentions no such pricing.
Despite its technical subject matter, this book is not a difficult read. The author's writing style is usually light and friendly, especially in the preface. In a few places, the phrasing is a bit too terse, which might prove momentarily confusing to some readers, e.g., "Function and constant aliases work the same as [those of] classes" (page 11). The text has some errata (aside from the two, as of this writing, already reported): "curl" (pages 15, 220, and 222; should read "cURL"), "a an argument" (page 33), "Prepared statement [to] fetch" (pages 99 and 100), "with [the] php://filter strategy" (page 110), "2 Gb" (page 129; should read "2 GB"), "the the" (page 154), "path to a the code" (page 176), and "Wordpress" (page 190; should read "WordPress").
One weakness with the book is that for several of the topics — including some critical ones — there is not enough detailed information provided that would allow one to begin immediately applying that technique or resource to one's own coding, but instead just enough information to whet one's appetite to learn more (presumably from another book or a website). Secondly, some of the narrative — particularly near the end of the book, when discussing various tools — would be of less value to anyone not developing analytics environment. Beware that some of the tools require numerous dependencies. For instance, do you have Composer, Git, MongoDB, and its PHP extension installed? If not, then you won't be using XHGUI. Also, some of the installation and configuration steps are quite lengthy, with no details provided for troubleshooting issues that might arise. Lastly, despite the promise that any reader with only basic programming knowledge will be able to fully understand the book, such a reader would likely find much of its contents mystifying without further preparation from other sources.
Nonetheless, the book has much to offer, despite its slender size. Numerous resources are recommended — most if not all apparently vetted by the author, who clearly has considerable experience in this arena. Some valuable techniques are presented, such as those instances in the text where the author shows how to use iteration on large data sets to minimize memory usage. In addition, the example code demonstrates that the author has made the effort to produce quality code that can serve as a model to others. Modern PHP does a fine job overall of explaining and advocating the newer capabilities of PHP that would attract developers to choose the language for building state-of-the-art websites and web applications.
Michael Ross is a freelance web developer and writer.
You can purchase Modern PHP: New Features and Good Practices from amazon.com. Slashdot welcomes readers' book reviews (sci-fi included) -- to see your own review here, read the book review guidelines, then visit the submission page. If you'd like to see what books we have available from our review library please let us know.
Best practice for PHP... (Score:2, Insightful)
Best practice for PHP: don't use PHP.
Re:Best practice for PHP... (Score:5, Funny)
Best Practice to make PHP run fast:
Run. Fast.
Re: (Score:1)
It's nice enough for building a Personal Home Page, anyhow.
Re: (Score:1)
hah (Score:1, Insightful)
The best practice for using PHP: don't use it at all!
Comment removed (Score:5, Funny)
Re: (Score:3)
Someone who hates everything else even more?
It has the advantage that it does backwards compatibility well with advance notice when a feature is about to disappear This means that if I need to upgrade my PHP application, I am sure to have a version that supports both the new interfaces and the old deprecated interfaces and more importantly it means that if I have a number of different apps that I need installed, I am not likely to need to move them each into their own VM. Python as an example of everythin
Re: (Score:1)
In my experience people who were too lazy to learn perl in the mid 90s and who are not experienced in Java.
Re: (Score:2)
Not sure what you mean, i mean there are *bad* java web apps, but if you choose well from the many design paradigms available in the different Java Frameworks/Libraries, then you can obtain pretty well defined web apps.
PHP is fine (Score:5, Insightful)
It gets the job done quickly and easily, and if you find or write a good foundation of libraries and classes, the code is elegant and easy to understand as well. Just like every other language.
Re: (Score:1, Troll)
PHP is inherently insecure. You can't have a web platform language with constant patches. One day your fine, the next, rooted. Stay away.
Re: PHP is fine (Score:1)
How the heck is the parent "trolling"?
That comment is completely true!
Go check out the PHP changelogs. Some of the bugs being fixed in the 20th or even 30th or more patch release of the various stable releases are unbelievable.
Clearly there is a quality issue at play when the relatively recent 5.4 version has had 39 patch releases, and the newer 5.5 version has already had 23.
Re: (Score:1)
write better code or learn how to secure your site/server... preferably both.
i have 5 year old code running on a nearly-as-old version of php and mysql.. no security issues of any kind... on the same server is a couple ancient joomla (yuk) and wordpress installs.. same deal.. the server is secure, the sites are as well despite their obsolete software, and have a few nifty home-grown security measures in place, even the known exploits in both of those very hacker-friendly applications are totally unexploita
I CAN tell you. Autoglobals, for 1. Much better (Score:3)
I CAN tell you why PHP 3.x and 4.x were used in a lot of projects with security problems. I've made many posts here going into detail. The biggest thing was probably autoglobals. That was insane for a WEB language, even one then intended to be easy. It might make sense for local macros (vbscript) that are supposed to be written by non-programmers.
If you combined few of PHP 4.x blind spots with stupid Plesk running the script via suexec, you either found out you quickly got owned, or more often got own
Re: (Score:3)
Re:PHP is fine (Score:4, Interesting)
Re: (Score:2, Interesting)
You clearly never had to use ExpressionEngine. If you think PHP was written by very inexperienced programmers, you're in for the shock of your life.
ExpressionEngine has something called "Global variables" which are in fact CONSTANTS. And that kind of nonsense is just the tip of the iceberg. Look up their "parsing order", it was created by insane people with no previous programming knowledge.
Re: (Score:2)
Re: (Score:2)
I have worked extensively with both.
Expression Engine is just a bunch of ... huh?? It's not bad, but anything other than what they give you can be a pain in the ass. CI in general was always sorta good but shoulda been better.
Magento has clearly been something that redefined PHP applications. The 1.x branch is going to go down as some of the least maintainable software ever written, but it was bad in a very productive way. 2.x (which you'll probably be seeing in a /. ad in the next few weeks before the co
Re: (Score:2)
Re: (Score:2)
I think the problem a lot of programmers have with PHP is that it originally was written by very inexperienced programmer(s) and it still (?) shows.
(1) So was Python.
(2) So does Python.
Python is only slightly more consistent than PHP, but gets much more bad press than PHP. I always wonder why that is.
Re: (Score:1)
VHDL.
Wow. Unlike PHP, Perl, C, C++, C#, Pascal, and ECMAScript, VHDL's got a whole new paradigm.
the code is elegant and easy to understand as well. Just like every other language
Maybe I need to learn a new language.
Re: (Score:2)
Re: (Score:1)
Actually, it's sane is to write
haystack.find(needle)
or
find(haystack, needle)
for same reasons. Collection first, then operand. If you want "english", use COBOL.
Re: (Score:2)
Then explain
array_search($needle, $haystack)
Re:PHP is fine (Score:5, Funny)
Sometimes bad tools are just bad. (Score:2, Insightful)
I don't get this it's-never-the-tools-but-always-the-programmer attitude that you have. I've seen it a lot at Y Combinator's Hacker News site, too. It's really a dumb concept.
Some tools are inherently bad, and irreparably broken, even in the hands of the most skilled and experienced practitioners.
Even the best master carpenter can't use a blob of Jello as a hammer or a saw. That doesn't mean the carpenter is no good. This carpenter is the best there is. He's just using a totally inadequate tool.
It's the sam
Re: Sometimes bad tools are just bad. (Score:1)
The fact that we have to hold your hand through this process indicates that you should never be allowed to develop or work on any sort of software, ever.
PHP's broken type system, its broken operators, its remarkably inconsistent standard library, its awkward syntax, its quirky and unexpected semantics, and its buggy implementations are good places to start when learning about its serious problems. The more you look into such things, the more you will learn about how flawed it is.
Re: (Score:2)
If the type system is broken, how is it broken? Broken meaning what? If you're going to make a compelling argument, you might want to start simply and at least give a practical example.
You've failed to come up with reasoning compelling that would cause someone with customers and a revenue stream to take notice. Would you put up with that kind of failure in your utopia?
My classical inheritance is intact, my multi-inheritance via composition (traits) is intact, I have lambdas. I have a lot less than that in
Re: (Score:2)
The problem is that people like you will continue to deflect the problems away because you're not competent enough to understand them in the first place. You don't know your code is broken.
The fact that you don't know that the type system is broken means that you're wholly unaware that any code you have written involving integers can behave completely differently when you move your codebase from a 32bit system to a 64bit system. It means you probably don't realise that your code is failing when you expect '
Re: (Score:1)
Re: (Score:1)
Re: (Score:2)
Re: (Score:2)
And recently all over again with the EDM kids and their Javascript. My lawn, etc.
Re: (Score:3)
Blaming the language for bad code is asinine.
It's not asinine but it is probably overly harsh.
PHP is popular because it's easy for beginners to learn, easy to get stuff done quickly & simply, and easy for programmers familiar in C & C++ to start web development without having to grok a completely unfamiliar language.
PHP is bad because it's easy for everyone using it to write insecure code.
Re: (Score:2, Informative)
Only a fanboy makes excuses for why they are too blind to see the many ways it is broken. PHP was designed and developed by a complete fucktard. Let's look at some code ...
Note: The online manual is completely useless:
* true http://php.net/manual-lookup.p... [php.net]
* false http://php.net/manual-lookup.p... [php.net]
* TRUE http://php.net/manual-lookup.p... [php.net]
* FALSE http://php.net/manual-lookup.p... [php.net]
More stupid shit PHP does ...
Re: (Score:2)
> You say zero and 0 and "0" the same.
No, not me, I'm only listing PHP's stupidity.
Here is a table showing how PHP's == operator is completely fucked up ..
http://habnab.it/php-table.htm... [habnab.it]
Of Javascript is just as retarded ...
https://dorey.github.io/JavaSc... [github.io]
Re: (Score:2)
Did PHP rape your dad or something? That's the only way I can imagine it makes you this angry. Seriously, this is pathetic. PHP works for many people who don't seem to find fault with the criticisms you've outlined. They either don't notice it, work around it, or work in the language with such a level of abstraction that they are not a problem.
So please grow up - you are just embarrassing yourself now, with your neckbeard coder rage.
Re: (Score:2)
Ad hominem fallacy. The reasons _why_ I hate PHP are irrelevant.
PHP is a shit design language. Education is the only way to get people to see its problems.
> They either don't notice it,
Typical head in the sand. Ignoring a problem doesn't make it go away.
> work around it,
Sometimes you can, however one can't work around fundamental inconsistency embedded in the design.
> or work in the language with such a level of abstraction that they are not a problem.
Exactly; They use a better designed language
Re: (Score:2)
> from some ideology that isn't based in rational discourse. /sarcasm Ah, so consistency is irrational now.
Only in a brain-dead language can you do stupid shit like this:
You PHP / Javascript apologists crack me up.
Re: (Score:2)
> Lisp is perfect for you.
We're not talking about other languages. We're talking about how fucked up PHP is.
> it's not like the interpreter is making arbitrary decisions
Counter-example:
http://3v4l.org/tRieg [3v4l.org]
Re: (Score:2)
I think I've discovered your problem. It seems that the code you write serves no purpose.
If your goal is to write code that serves no purpose, PHP is not for you. You might prefer KAREL.
Re: (Score:2)
Let's talk about a language for noobs designed by a boob:
Re: (Score:2)
If you write a good foundation of libraries and classes you'll need a hack like APC to get any decent execution speed. It also sucks at memory utilization. Everyone likes to link to that "fractal of bad design" article, but it's pretty much just a bunch of whining. Here's a real article that just plain hurts, it has to do with PHP's memory allocation: https://nikic.github.io/2011/1... [github.io]
Re: (Score:2)
Why are you not using Zend OPCache? Let's go, time to migrate beyond 5.3.
Re: (Score:1)
Damn, snagged!
Re:PHP is fine (Score:5, Insightful)
This is bullshit. A shitty language promote shitty code. Aside from the whole taking pride in your work and other "soft" effects, in PHP's case, there are several big, concrete instances of this happening.
For example, older versions of PHP were obviously designed without any clear understanding of how a web request operates. So, for example, you'd have SQL escaping happening in the input layer rather than at the database layer. Nobody who understands what they are doing would design something to work that way. But the core PHP devs totally fucked up in the beginning. They have since started to pull this crap out of PHP, but take a look around. Big, widely-used PHP packages like CodeIgniter have replicated this topsy-turvy design fuckup even in recent versions. That's no coincidence - that's inherited from PHP's design flaws. The blind led the blind into hell, and this crap permeates the PHP developer community as a result.
Likewise with the cavalier attitudes towards correctness. Error handling, character encoding, testing, release management, things like that. Where PHP fucks up, the community is sure to follow. The low quality of PHP has a direct negative effect on the code its fans write.
I'm fed up with the equivocation PHP fans trot out whenever any criticism heads their way. Yes, the quality of a language really does have an effect on the quality of the code you write with it. This is plain for anybody to see, and if you don't see the difference in quality, then you should seriously question your competence.
Re: (Score:1)
Re: (Score:2)
"I'm fed up with the equivocation PHP fans trot out whenever any criticism heads their way. Yes, the quality of a language really does have an effect on the quality of the code you write with it. This is plain for anybody to see, and if you don't see the difference in quality, then you should seriously question your competence."
Absolutely and evidence of this is always only a Google search away. Search on how to do something with a database and the results you get are riddled with things like SQL injection
Re: (Score:2)
To follow on from this: Language Community Litmus Test: Database Placeholders [wumpus-cave.net]. An informal survey shows PHP joint bottom, with all but one of the top 5 hits for "PHP database tutorial" promoting insecure methods.
And, as you mention, the official PHP tuto
Re: (Score:2)
Bad coders are irrelevant to the fact that PHP is objectively and measurably bad in design and implementation. It started as a toy, and that pedigree still shows.
Not only is it still the mess of internal inconsistency, braindead weak-typing and promotion, and anemic text support, but there's some amazing -- I mean brilliantly, awe-inspiring, mind-boggling -- idiocy in some of its baked in APIs: LDAPs ldap_list() vs ldap_read() vs ldap_search() all perform the same operation but with different scopes, none o
Re: (Score:2)
Re: (Score:2)
Suppose all guns came without safety catches. I now go and blame this technical oversight for the increase in people with blown-off heads.
You now claim that blaming the safety-catch-less badly designed guns for the casualties is asinine.
> It gets the job done quickly and easily,
So does a gun without a safety catch.
Re: (Score:2)
Re:PHP is fine (Score:5, Funny)
The problem with the PHP community is that it's filled with the kind of people who feel it's good idea to work on PHP.
Are you down w/ OPP? (Score:1)
I'm not down with Other People's PHP (OPP), knaw me
Never understood the PHP hate (Score:3, Insightful)
I've written PHP, Java, Javascript, C#, C++, C, and VB (and have dabbled in Ruby and Python), and I still don't get the hate for PHP. Granted, weakly-typed variables are a bit aggravating, but that's the only major complaint I have with it.
A better model for Dynamic Typing (Score:2)
A lot of that can be alleviated simply by having a language that does not overload operators across types, such as "+" for addition and concatenation, and by having optionally type-validated parameters.
ColdFusion may suck in other ways, but it got these two things mostly right. Witness the function parameter (argument) declaration definition:
Re: (Score:1)
The summary does mention JavaScript. And Php still has the problem for equality operators (greater than, equal, etc.). Then again, ColdFusion didn't quite settle equality comparing either.
Re: (Score:2)
PHP is a piece of shit and this is why (Score:1)
Re: (Score:2)
That's a great list!
Analysis of the PHP source code, showing some of the ways PHP is fucked up and hopeless beyond repair:
http://www.viva64.com/en/b/027... [viva64.com]
Couch programmers bashing again. (Score:5, Insightful)
Re: (Score:2)
It's got nothing to do with laziness, at the end of the day the fact remains that PHP has an awful lot more inconsistencies, and has an awful track record on security, stability and functionality.
I'm skeptical that anyone who claims to have a good depth of experience of PHP but claims it's as fine as anything else really does have the experience they're claiming. As soon as you need to start doing anything serious, like say, making use of threads, PHP's deficiencies rapidly come to the fore when compared to
Re: (Score:2)
Hmm. No idea what the fuck just happened to the rest of my post, lucky Slashdot isn't written in PHP or I could blame it for that too :)
Anyway, basically my point was that it's really not in question that PHP has a number of problems that it's competition simply does not have, those problems are not caused by the programmer, they're caused by the language and it's libraries.
Yes you can write bad code in .NET, Java, C++ and whatever else, you can also write good code in PHP. None of that is in doubt, but it'
Re: (Score:2)
That requires a few assumptions though, that you're using HHVM rather than the official PHP interpreter and that your application really is IO bound (which is entirely application dependent), and finally that you're not fully optimising your .NET, Java, or whatever else environment too.
Even given these assumptions though, there's still the problem that PHP simply doesn't offer the breadth of support for hosting your application to optimally cater to different cases in the first place. For example, with WCF
Re: (Score:2)
"HHVM just closes that gap entirely"
This is wholly false, HHVM is still a long way behind the level of JIT optimisation that both the JVM and the CLR perform, in part because PHP was never designed with the intention of being JIT'd from the outset making it much harder to JIT well in the first place. The amount of language inconsistency, edge cases where it contradicts itself and general design whereby things have been bolted on unplanned and ad-hoc all but guarantees you'll never write a JIT compiler for P
Re: (Score:2)
The second half of the paragraph proves that I understand VM technology in quite a lot of detail, and understand the sorts of difficulties involved in moving from a language to executable code through an intermediate form.
I know that HHVM doesn't support strict PHP which is presumably what you're referring to, but if you're confusing the moderate changes made to make it work in a JIT at all with the complete break needed to be able to act in a competitively optimised JITted environment then it's not me that
Re: (Score:2)
Yeah you're right, I haven't touched PHP in a couple of years now so I haven't seen anything about (nor can I find anything even now) PHP's new async support for the things you list. Yes I'm aware it's now got some half-arsed threading support hacked in to move away from basing attempts at multi-threading on curl hacks, but it's not me you need to be telling this to - it's the other guy whose argument that PHP is fine performance wise is because you're spending 90% of the timing waiting on blocking IO, whic
Re: (Score:2)
Okay, so it sounds like I was right then after all if you're conflating curl hacks which require the spawning of a completely different process and a full blown TCP connection to achieve anything with an actual proper threading solution or async IO implementation (FWIW I find it amusing that you claim multithreading and async IO are completely unrelated things and then pretend curl is an async IO implementation- facepalm. You don't even know how PHP's curl library works).
I was going to reply in a bit more d
Re: (Score:2)
"multithreading can be used to implement async io but it is not a requirement, see node.js."
Oh god. Node.js uses IOCP, which implements a thread based model. Did you think it used magic or something?
No wonder you're posted AC, you're just embarrassing yourself. Acting as living proof that PHP developers are clueless. Well done, you've successfully proven my points throughout.
Re: (Score:2)
Oh are you still here embarassing yourself? I thought you'd gone. Processes != threads. This is CS101.
P.S. The way you speak of IOCP shows you don't even know what IOCP is or how it works.
Is that you Bronscon?
Re: (Score:2)
You still seem to think spawning new processes is in any way a passable form of multi-threading in a high load environment as opposed to spawning new threads. This alone shows you're not fit to have any kind of discussion on this topic.
For starters, it means you can handle drastically fewer concurrent tasks because it has by far a higher memory and CPU footprint to do so. That's before you factor in the problems of shared data meaning you're probably also duplicating data in your separate processes (i.e. ea
Re: (Score:2)
[citation needed]
I miss Slashdot / get off my lawn (Score:2, Informative)
The comments on this article are a horrible cesspool worthy of Youtube commenters.
PHP hatred is the in thing, I get it. But what do these comments have to do with the fine article? How are we improving as an industry by hating on PHP? How are we encouraging the next generation of coders by these vapid, ignorant comments?
If you agree, I invite you to join the rest of us Slashdot refugees at HN. Ouch. So sad.
Not By Choice (Score:2)
This is mostly because there are few practical alternatives on the client side. You can't have the user install say Python on the client side if you want to use Python. It's the QWERTY of programming languages: you are stuck with it because everybody else is also stuck with it. They are not going to fudge their browser just for your particular site.
While J
Re: (Score:2)
Javascript is what makes pages load on peoples' browsers in seconds instead of milliseconds. It can turn a relatively recent computer or tablet into a slug.
Keep your 'code' outta the marked up text that I'm trying to read. Nobody cares that you think you're a 'web developer' because you can slow down a stream of text that your 'users' are trying to fricking read.
Re: (Score:2)
OK, Grandpa. Sorry. We'll get off your lawn now.
You can install NoScript and have to refresh your pages time and time again any time you want to use them, wasting seconds and many KB in the process. The rest of us will keep using the tools which give us the web we want to use.
Shouldn't you be napping somewhere?
No Static Typing (Score:4, Interesting)
For all of PHPs many, many horrors, the one that actually got me the most is the lack of static typing when working with a large body of PHP code (Wordpress). One can wonder at many of the details of arrays etc, but once you know all the gotchas then you can work with them. But no static typing gets you over and over.
It is also interesting that 40 years of careful research into programming language design, including very sophisticated systems such as Algol 68 and Common Lisp, had absolutely no effect on the design of what are the most commonly used hack languages today. (PHP and C.)
Re: (Score:2)
"It is also interesting that 40 years of careful research into programming language design, including very sophisticated systems such as Algol 68 and Common Lisp, had absolutely no effect on the design of what are the most commonly used hack languages today. (PHP and C.)"
You may have won the Internet today. I salute you sir.
(btw I'm totally stealing this)
Re: (Score:2)
It is also interesting that 40 years of careful research into programming language design, including very sophisticated systems such as Algol 68 and Common Lisp, had absolutely no effect on the design of what are the most commonly used hack languages today. (PHP and C.)
Thank god for that.
Re: (Score:2)
Without any actual evidence, the 40 years of careful research is nothing more than navel gazing. This research has been the equivalent of "don't you think this is true? here's why" which is not how any kind of science is established.
PHP best practice (Score:2)
Don't.
PHP - Best common practices: (Score:2)
Don't use PHP. Use node. If you can't do that, use C. Not C# or C++, C. What, are you eight or something?
Re: (Score:1)
Even Wikipedia's transitioning from PHP to Lua.
[citation needed]
Re: (Score:1)
Re: (Score:2)
http://blog.wikimedia.org/2014... [wikimedia.org]
Re:Yes. (Score:4, Insightful)
after years as the target of criticism, the PHP computer programming language is seeing a revival
PHP has a really bad reputation, probably well-deserved. I don't know if it can overcome that at this point.
It can be implemented well. I have seen it. The trouble arises when folks insist on over-engineering their PHP solution. I won't mention the photo project, but one time I was looking for the value of a variable. After days of grepping and sifting through thousands of lines of code, I found out that this variable was nothing but a constant in a very deeply embedded class structure. Why they created this whole class and derivatives just to set a constant, I can only guess that they freebased the OOP Kool-Aid.
I don't give a shit what your CS prof says, there is nothing wrong with defines. Or 'goto's for that matter. There's nothing more annoying than a method/function that's hundreds of lines long just because the programmer didn't want to use a 'goto'.
If your function is hundreds of lines long just because you didn't use a goto, you're still doing it wrong.
Re: (Score:1)
A lot of BS about PHP comes from developers of more OOP/MVC coding designs using Ruby on Rails, where as I think Ruby on Rails is a mess.
look at the mess calling the mess a mess!
Re: (Score:3)
Just install one of the many many WAMP packages (WAMP = Windows + Apache + MySQL + PHP). Typically you just run a setup executable and get a ready to use installation of Apache with PHP and a MySQL server, which normally includes phpMyAdmin and some other helpful stuff.
Re: Facebook was written in PHP (Score:2)
Disclaimer: I genuinely like PHP.
Facebook was originally written in Facebook, yes. However, you are missing the important fact Facebook took it upon themselves to fix a bunch of PHP's mistakes with HipHop PHP, later named HHVM.
I've actually played with HHVM a bit. It maintains mostly backwards compatability with PHP code, but adds optional static typing and a few other goodies.