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
Nacho Colomina Torregrosa -
TAIO Sylvain -
Asfia Aiman -
Jamir Hossain -
Top comments (72)
<?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.