Part of a new series! Feel welcome to dip in and weigh in on a past question.
Let's say I've never used PHP before. Can anyone give the run down of what the language does and why you prefer it? Feel free to touch on drawbacks as well.
Part of a new series! Feel welcome to dip in and weigh in on a past question.
Let's say I've never used PHP before. Can anyone give the run down of what the language does and why you prefer it? Feel free to touch on drawbacks as well.
For further actions, you may consider blocking this person and/or reporting abuse
<?php
, so you never forget which language you're writing$
, so you always feel rich😂😂😂 10 out of 10 experts consider this a top comment.
oh yes, I feel rich heha XD
This might have been the greatest comment I've ever read here. I'm sold hahah!
Nice observation !
I've been using PHP since PHP2 (!) days. I did a serious site with it back in 2010, and am back into it after a 10 year break on a wordpress site. (I don't want to toot my horn, but I want to put this a bit into perspective: I'm a huge functional programming fan, I've written web applications in Common Lisp, python, node, C (!), perl, java, scala, C# over the years).
Things I like about PHP:
The main two for me are the speed and cgi-bin lifetime. Most of the reasons people hate on PHP are kind of non-sequiturs. I don't care that people find it easy to write bad code in PHP, I have all the tools I need to write good code, and bad code I can easily isolate, contain and replace.
I assume this is directed at someone with programming experience going into PHP. I would be quite wary giving PHP as a language to a beginner, without proper guidance. But what language is good for a beginner is a topic for another day!
This. It has been a really interesting journey to debug node memory leaks that could go on for weeks without crashing or crash four times an hour. This is rare (but ofc possible) with php by design being request scoped.
The typing issue is interesting. Its a script language with types added, to some extend. I see it as TS is for JS, more of a tool to impose clean code and better structure and self documentation than something that "makes you write bug free code".
Php can be really fast, but as with any tool you are the assembling man and feel free to mess it up here too. Its neither harder nor easier imo.
The most misunderstood thing is probably all the new devs who pick php up as first language and then they find something like Golang or C# and thinks that that solves all their issues and they bash on php. I'd say no language is better than the programmer and you should learn as much as you can about how to use the language properly.
• No compiling
• Live bug fixing on prod
• Cheap hosting
• WordPress
• Abundant of devs
Explain "live bug fixing on prod"? Is this a tooling thing?
Hah, it's a joke because you can vim and edit the code live. It's risky tbh. There is no recompiling needed
Ahh I see. I guess that's similar for a lot of interpreted languages/runtimes, though (at least ones that use the same one-process-per-request model)?
Exactly :)
This is not a plus, except if you have a very small website which doesn't have much visitors and you can afford breaking things from time to time.
Modern PHP isn't a bad language. It's just been given a bad name by the lowest tier of WordPress plugin installers who call themselves developers. If you don't touch WordPress with a bargepole and work exclusively with a modern MVC framework you can have a pretty decent experience with it.
The modern PHP ecosystem is pretty nice. Composer is about as good a dependency handler as I have seen elsewhere, and these days most packages you may find are decent quality, typically with proper tests, and static analysis is becoming increasingly widespread.
The tooling is pretty decent too. I use Intelephense in Neovim and that gives me a good experience. I find Psalm incredibly useful too.
There's also plenty of decent content management systems available. I really like Statamic - it's a much better developer experience than using WordPress, and although it comes with a price tag, I found it covers everything I typically need out of the box, whereas WordPress needs several paid plugins for most use cases.
I’ve had a joy working with php for the last 4 years (it was also my starting language about 10 years ago, before I switched to C#, Objective C, and Java). Overall, modern PHP is a lovely language to work with. Though, I probably wouldn’t use it as much if it wasn’t for Laravel. But I could say the same for C# and .NET, or Swift and UIKit. What matters is, how can I achieve the app I want to build, while all the boilerplate like Auth, AuthZ, ORMs, etc. are all handled already.
I recommend anyone to try PHP and Laravel. It’s hard to go back.
It has a consistent API!
/me fleeing
lollllll is it not consistent? I'm not familiar with PHP, only ever wrote a few lines, I've heard that it's a "really bad language" (especially on tech youtube) and that i should stay away
@dhravya Don't trust simply on the basis on what you hear, There is a lot of hate going around for php, but there is a reason It is still going so strong. Also These hate comes from old php (php <=5). The php that you would learn today is completely different language, not just an incremental upgrade. From personal experience, PHP-8 is almost as good of experience as Java J2EE for large scale Application ( now known as Jakarta EE, not to be confused by similarly named Apache Jakarta).
About language inconsistencies, it will make sense when you learn that it was borrowed from underlying system (c or perl depending on module. ). And regarding the community inconsistencies like different framework had different coding guidelines ( mostly for those which existed before PSR), That is true for almost any language (except for Java, Those guys created strict coding guidelines from the day 1). ANSI-C is quite different Turbo-C, Comodor basic was quite different than atari-basic even though they are both based on MS Q-basic. Now, almost all frameworks are getting streamlined in coding guidelines by adopting PSR at some level.
I highly recommend you to watch 25 years of PHP from its creator Rasmus Lerdorf, During lunch on some weekend, as a casual watch recommendation.
Those who say "It's a really bad language" has never learned php properly enough. Sometimes not all book should be judge by its cover alone. PHP as a language might feel weird at first, But it is a very practical language. Going through the underlying c code, is also an awesome experience, you will learn a lot of micro-optimization tricks which can be translated into any language you work with.
Don't take people's opinions on programming topics too seriously, form your own opinion. Not that you should look into PHP, but if you don't understand the reason why someone thinks a technology is bad, it often means the person stating that actually doesn't know either.
+100. Don't listen to me :D I made a joke. PHP is (was?) known for having inconsistent API but I am not an PHP expert by any means.
I have some experience with PHP, although I wouldn't call myself an "expert." However, the inconsistency of the API is the first thing I noticed. Ruby has been designed with the principle of "minimal surprise," PHP seems designed to maximize the surprise.
Fortunately, there is a nice manual online, without that programming in PHP would be a nightmare.
There's also some good replacements, for example the laravel helpers. I very rarely use the standard library.
It does have inconsistent api for functions, however the reason is that function names are same as underlying libraries function names.
So there is strpos and str_replace (str meaning string), but they differ in naming because strpos is from one library and str_replace from other.
That is the short explanation at least.
example from built-in function of core php
array_map receive callback first, array second
array_reduce receive array first, callback second
there are quite a number of this kind of inconsistency around
Well you just lack experience if this is your biggest pet peeve. I agree, it's not a perfect system, but if you only pass an array to array filter it will filter out falsey values without you having to specify a callback. There's benefit in that
this is not the biggest but it's the context of what I replied to.
and if array_filter have benefit of using array first, why not all other functions do the same?
Either way, if you are coding in anything other than Notepad, your IDE will most likely help you with the argument order so in that regard, it really is a moot point. Most frameworks have all of this abstracted already. They also abstract strings. I don't see it being much different than Java world. Nobody codes in plain Java nowadays. Everybody simply learns the spring framework and "the spring way of doing things" and that is it.
People say the same about almost any language.
You can think on it as Python example, it was released in 1991 yet it was considered garbage by many people, something that you know it exists but don't even consider using.
Two decades after it became one of the top languages to consider.
Trends are trends and community hype is present as well, check your sources, search for information, try it yourself and take your own conclusions.
Remember that is better to say "I don't like Java because it's verbose" than saying "Java is a shit"
Yep, I agree. I think I heard a saying on the lines of "If a language isn't hated, it's bad"
Making decisions based on the opinions of so-called "expert" is risky
Totally agree! See my response above. It was a joke. I'm not a PHP export by any means so don't listen to me. It was many years since I last used it :)
I used to use Django and always wanted to work with it professionally, but reluctantly applied for PHP jobs earlier in my career because that's what there was where I live. At my second web dev job (not second overall as it's a second career for me) I was mostly working solo, and used CodeIgniter for some projects, but it became obvious quite quickly that it was a Fisher Price My First MVC Framework, so where I could I used Django instead - it was easier to manage dependencies, far easier to write tests, and had the killer feature of the built in admin.
Fast forward to 2015 and after years of wanting to drop CodeIgniter completely and move to a more modern PHP framework for new projects, we made the jump to Laravel, and it was the first PHP framework that was good enough that I felt comfortable using it for everything. I haven't used Django since.
I know Laravel is big and most people know it, but I had a similar experience with Yii. It has most of the comforts of Django, but PHP.
Hosting for PHP is basically a commodity. The number of providers is large and the product is largely the same and you know what to expect. I find other types of web hosting product to be unfathomably complex, with byzantine pricing tiers. This may be because I'm old and therefore not very tech literate, but PHP hosting is a product category I more or less understand. At my IQ level, containers and droplets and other abstractions seem like a conspiracy against comprehensibility.
According to w3techs, php is used by 77.4% of all the websites whose server-side programming language we know.
I am going to pick up a book and start learning php because it is here to stay.
Edit: Wouldn't it be a cool idea to reinvent Forem with Php?
Yeah, but how do we know? The letters "php" in the URL?
Yup! That's one way to find out the language being used. Additionally, If the website is open-source like Forem, then you go to the place where the code is being hosted and find out what you are looking for. Besides, the following is a list of websites that you can use to gather information about a particular domain name, like, for example, dev.to:
In cybersecurity, gathering such info is known as reconnaissance or recon for short. I am not a lawyer myself, but I think recon is legal since you are just sniffing what is being cooked unless you take illegal actions based on collected information, such as exploitation. However, it is just a matter of opinion; the correct answer thought is to consult a lawyer to look up the laws that are tied to a specific region and vary from one place to another.
I'm php dev from over 12 years, I didn't touch wordpres yet.
That's enough to know that is enterprise stack.
How many other languages do you know that have a message error (partly) in Hebrew? 😁
"T_PAAMAYIM_NEKUDOTAYIM" is transliterated Hebrew and it means "double colon" (more literally, "double two-dots") You get this message if you use "::" where you shouldn't.
Don't worry. It is just another project idea:
There is a lot of aggressive hate for PHP for all the wrong reasons (most all link to the same article written over a decade ago that mostly doesn't apply to PHP today, or things that apply to all interpreted languages equally)
Beyond that, I'll say this: PHP has the most enterprise friendly features of any of the major languages out there today.
Yeah, I'm going to get flack for this, but it from decades of experience maintaining systems that need 100% uptime.
PHP has the absolute most enterprise friendly MySQL connector outside of the C language itself, while still having the nicety of easy string manipulation. PHP has the most graceful support for distributed SQL databases with its connector, being able to handle database server failures better than any other language.
I'll admit, I'm kinda biased in this regards, however. As I'm the one that helped bake in some of that functionality. There are some extremely rare bugs in MySQL/MariaDB that can entirely hose an application server. I had one of these such bugs take out an entire fleet of application servers, getting them all in a locked state, essentially the DB DoSed the application servers.
Thanks to some of the additions I helped with to implement in PHP's connector, this is no longer an issue if the connector is configured properly. However, these same fixes don't exist in other languages like Python or JavaScript. DevOps generally just rely on "oh, it broke, let's reboot and hope it doesn't happen again" instead of doing the full investigation into the language's source code itself, the connector, and the database's source code.
Having done all that work, I know undoubtable that PHP can handle a fair bit number more failure scenarios than other languages, having done this at scale for 15+ years.
So yeah, if you're just starting out and have a single app server and a single database and rebooting them is fine, then maybe this isn't an issue. But if you're running thousands of servers at scale and need reliability and uptime, PHP's ability to horizontally scale easily mixed with its MySQL connector's ability to gracefully handle more situations makes it prime for very large workloads.
Its not obvious up-front, but PHP has more enterprise grade features than just about anything else out there.
In addition to what has already been mentioned, this guy here levelsio makes $3.15M per year from a couple of SaaS projects, all written in PHP and often just a single
index.php
file. Pretty impresive for a language that "dOEsn'T sCAle".What it does: It was designed to add server side functionality for webpages but it's grown to do a lot of things. You can build pretty much anything with it these days. (Okay, maybe not anything, but a lot of things.)
Why one might prefer it:
I didn't care that much about PHP but learned just enough of it so I could read the Laravel source code, which is one of the best-written codebase out there that also reads like prose and is just a pure joy to read.
Even though I work with Rails at my day job, absolutely love Ruby, and don't see myself programming in PHP any time soon, I have learned so many valuable things about writing software well, by reading Laravel's source and how much care, detail, and attention Taylor Otwell (creator of Laravel) put into it.
This may sound too lofty, but at this point I've almost made it a habit to read at least some piece of Laravel code, be it a method or a class, or even documentation before going to bed. It just makes me happy.
github.com/laravel/framework
Personally, I've never worked on anything that couldn't be accomplished with PHP. I think the reason I love the language so much is due to the Laravel Framework and Jeffrey Ways tutorial site Laracasts. Laravel is the best framework I've gotten to work with to date. Everything is just so readable, I have yet to see anything else that looks as pretty as Laravel code. The framework really does come with all the batteries included. Not sure how to do something? There is probably a laracasts video for it, and you'll be able to find it in a jiff due to Jeffreys great ui/ux on the site. Laravel docs are also incredible. So ya, Laravel is the selling point.
Do you consider yourself a good engineer? Well, this is the chance to demonstrate it. Here's a language that has almost no rules, you can make real atrocities and yet make it work. The only thing that separates a horrendous, lovecraftean mess from an elegant and well engineered solution is YOU.
You can have class, constant, function, method and property with the same name.
We all know PHP gets a lot of hate.
But it makes it really easy for a beginner to build a web project.
You might hear Junior Developers saying that PHP is slow, but they might forget that Facebook ran on PHP for a long time, and they're still using it in many components.
I wouldn't pitch PHP but Laravel, a very well designed framework. But, PHP itself has also improved by leaps and bounds over the years. It's like Javascript - there's the good, the bad and the ugly - just as with JS, just use only the good parts of PHP.
PHP is the only language that tries to improve. Other languages force the whole community to adopt design flaws. Also PHP stands for "PHP: Hypertext Preprocessor". Don't ask me what PHP stands for.
There is an old video from creator of PHP, Rasmus Lerdorf. Its called 25 years of php. All I need to pitch for PHP is to watch the video.
The old school programmers stories, back when people used to program to solve real world problems and have fun while doing that, is something I have always been fascinated about. But Rasmus Lerdorf takes it to all new level. Suddenly, all the memes and jokes about how weird php language is nullified, you start realizing how practical language actually is.
He goes through what php was (php<5.x) what php will be (php >7.x). It is surprising that they managed to completely reinvented the language, yet managed to provide a proper upgrade path. Unlike python which was a mess for switching from 2->3.
On top of that, he doesn't just say that there are performance improvement, he talks about how less cpu resource means less carbon emmisions. He talks about how someone created a relief service in few hours after the country was hit with earthquake.
Pros:
Cons:
My anti pitch
hackernoon.com/is-php-really-dead-...
hackernoon.com/is-php-a-dead-langu...
PHP, in the its recent version, has become very riable. And it offers the flexibilty of a dynamic type language with the secureness of a strong type language. With PHP you can do, in a single line of code, what Java requires very more lines of code. Besides with the framework Laravel, if it used properly, you can do very ordinated and well organized projects. The problem is that with PHP you can easy break the rules of a well structured programming, so you could do a mess if you don't pay enough attention.
Looking forward to the Perl CGI one of these 😅
In genera writing PHP is way shorter than writing Java or C# which are usually more verbose.
Some sources say over 75% of websites run on PHP.
Some sources say over 30% of websites use the WordPress framework, which is written in PHP.
Even visualstudio.microsoft.com/ is a WordPress site and therefore written in PHP. Way to go Microsoft!
Guaranteed jobs :D.
You can use Laravel.
What are your thoughts on PHP?
do not touch it.
PHP is a great language to use and works fantastically with frameworks like Laravel.
PHP is good for beginners and my favourite thing is that the name PHP is, itself, recursive.
Do you know that "php" is pronouced same way backward ?
For PHP you can finde the best Job Board for PHP Jobs
Just the code running the board is NOT starting with <?php ;-)
I have no idea... but I get a job, have a nice house and have a happy family. I learn in many things but i falling in love with PHP as a dot in circle lens.
LARAVEL
One of the languages which would't exists.
Wordpress uses PHP!
Compatibility
Simplicity
You can code it as you want