What are the pros and cons of PHP? I want to learn it but im not sure if its good or not

What are the pros and cons of PHP? I want to learn it but im not sure if its good or not.

Other urls found in this thread:

evertpot.com/PHP-Sucks/
twitter.com/AnonBabble

learn literally anything else

What is so bad about it?

overall it's a great language that has powered many great projects over its life, and is very available in terms of hosting, and arguably easier to learn

everything else depends on you

Nothing bad with it, easy to learn, good frameworks, PHP7 incredibly fast, LAMP easy to setup and ready to make projects

Have you ever heard the expression "it's not even wrong?" That's how I feel about PHP. There is nothing good about it, so it is not possible to point out bad parts. The entire language is the bad part.

It's widely considered one of the worst languages in existence. You may find yourself forced to use it at times, but you should use literally anything else if you have the chance.

If you want to see a laundry list of problems, look up "PHP: a fractal of bad design." I would link to it but the spam filter won't let me.

Someone post the image of rasmus and a bunch of his quotes about php

Incredibly easy to set up. Php7 is blazing fast. Laravel is one of the best web frameworks out there.

It's been fine for portal/forum/general web stuff for awhile. The LAMP/WAMP setups are pretty newb friendly too.

pros:
A lot of existing software use it.
cons:
The projects are much harder to maintain because of it.

All depends on you, if your are shit at coding, PHP will let you do shit, and you will, probably, blame the language.
If you're good enough, you will be OK

>PHP: a fractal of bad design
Thats old, PHP keeps evolving...
Same as Android or any other language...

The criticisms are all still relevant. The language has not changed dramatically in the last few years.

>pros
too many to honestly list


>cons
retarded updates that remove or fucking relabel an entire class of functions

i had a chatbot talking over sockets in PHP, it worked until they removed salsa20 support for zero reason and i had to convert the project to C++ (it was used for logon auth)

once in a blue moon an error will lead you to a line that has never existed

if someone tries to roll their own framework good fucking luck figuring it out

And wich language change dramatically?

In the past four years? Very few. Languages don't evolve THAT quickly.

Which is the point. A language that was shit four years ago will be shit today. Developers who were utterly incompetent four years ago will be utterly incompetent today. PHP cannot go from one of the worst languages in existence to something good in four years.

And most of the specific criticisms in that article still apply.

>pros

You can do back-end web development with it.

>cons

Everything else about it.

PHP's implementation sometimes could be 'harsh'.
The 'bad design' part it's really subjective.
Most depends on your work, if you have poor understanding of what you doing, poor understanding of the language, poor coding skills, what can you expect?

>Developers who were utterly incompetent four years ago will be utterly incompetent today.

Very bad analogy, 4 years is a long time to become decent at something. Unless you are Ranji.

I use php all the time. What language is better for say, reading emails, then generating an xml file and sending it through an api for a shopping engine? Or reading some xml files, then updating inventory, prices, and product information on amazon? Or reading some json from a remote website, updating the local database, then allowing people to make calls to that database through your own php implemented api?

Python?

PHP in itself is a jack off all trade but master of none. it's messy but it works and works almost everywhere.

Use/learn PHP7 if you want to, it's at least more ironed out. Remember to us pdo for every db connection.

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.

You pull out the pliers, but they don’t have those serrated surfaces; it’s flat and smooth. That’s less useful, but it still turns bolts well enough, so whatever.

And on you go. Everything in the box is kind of weird and quirky, but maybe not enough to make it completely worthless. And there’s no clear problem with the set as a whole; it still has all the tools.

Now imagine you meet millions of carpenters using this toolbox who tell you “well hey what’s the problem with these tools? They’re all I’ve ever used and they work fine!” And the carpenters show you the houses they’ve built, where every room is a pentagon and the roof is upside-down. And you knock on the front door and it just collapses inwards and they all yell at you for breaking their door.

That’s what’s wrong with PHP.

Well, thats a nice explanation, now i know whats wrong with it.
And what is the best web programming language? like one thats easy, and not haskell tier

yeah it was fun when 5.4 broke fucking everything

Pros:
Used everywhere, pretty easy to learn, PDO is sex, can get something up and running really quickly

Cons:
Type coercion, OOP implementation is shit, inconsistent naming conventions, integer promotion, most large codebases are unmaintainable garbage (ie wordpress, sugarCRM, Magento), probably way more I haven't thought about

Overall PHP is pretty bad, but you shouldn't avoid learning something as popular as PHP just because it's bad. Have it in your toolbox because you'll need to know it at some point if you're trying to get into software development as a career, but definitely get good with other tools as well.
source: in house PHP dev

Elixir is a million times better. Tooling, code, docs...community.

Don't listen to this guy, learn everything you can.

Nothing wrong with PHP when done right... the problem is that it's really easy to do things incorrectly and it will teach bad habits. It's a very easy language to pick up and it's quite forgiving... there is a metric fuckton of shitty PHP code out there.

I really like newer oo PHP with a good framework like laravel... but to be 100% honest, if you're going to learn a language it might as well be something else. Python would be my suggestion. If you're looking at web take a look at python using django. Good luck.

>I compared a number to a string and my program did something unexpected, it's the language's fault

And yet, no one here has bothered to make any better tools.

>Type coercion

I agree with all of your cons except this. It's very well documented exactly how type juggling is performed, and you have the option to not use it.

>PHP: a fractal of bad design.
Ahahahahaha, that's old as fuck nigga
The faggot who wrote that literally quit programming and whined about it on his blog. He also said C is shit.

this

There is no reason to use PHP anymore when you have light weight frameworks like Sinatra and Flask that handle everything so much better including routes, ORM, templates. Anyone who who writes SQL queries by hand as part of their backend code is a complete idiot. PHP also made a lot of stupid syntatic design choices like forcing $ in front of variables even outside of strings, using dot for string concat which precludes its use in object methods and forces arrow syntax. The only way PHP is usable is with a REST framework like Laravel or whatever, and even then the syntax is going to be so clunky and awkward compared with Ruby which handles OO much more seamlessly and intuitively

Yeah, I probably should have left that part out. Most people disagree with my stance on type coercion lol.

You're comparing Python frameworks to vanilla PHP instead of comparing Sinatra and Flask to Symphony and Laravel, you dumb fuck

you didnt read my whole post, I did compare frameworks, and PHP syntax does not work as a DSL like Ruby or Python because the OO syntax was bolted on as an add-on

>Anyone who who writes SQL queries by hand as part of their backend code is a complete idiot
Not every single thing can be solved with an ORM. SQL logic is a thing. Don't abstract shit away because you can't write a SELECT query to save your life.

>using dot for string concat which precludes its use in object methods and forces arrow syntax
Who gives a fuck? Really? It's a preference.

>forcing $ in front of variables
Blame perl. But still, having $ in front of variables is nice because you can clearly differentiate between variables and methods without an IDE coloring everything up.

>and even then the syntax is going to be so clunky and awkward
It's C++-like. Don't see an issue here.

>SQL logic is a thing.
youre an idiot

>Who gives a fuck? Really? It's a preference.
its not a preference, if you did anything beyond fizzbuzz you would know its the most important and prevalent syntax used in OO and backend DSLs

>Blame perl. But still, having $ in front of variables is nice because you can clearly differentiate between variables and methods without an IDE coloring everything up.
spoken like someone who can barely get through a Zed Shaw book, readability of syntax means the difference between spaghetti code and code that a large team can immediately understand and work on

>It's C++-like. Don't see an issue here.
that explains everything, if you think you can use Java/C++ programming on where everything is an implicit object with built in functionality, then you should really go back to /dpt/ and jerk off over K&R

>SQL logic is a thing.
>youre an idiot

He's not wrong. There are many use cases where writing a query or doing a batch operation in an ORM is less efficient than a standard query. They should be avoided, as one of the major benefits of an ORM is quick object translation into things like json. But I've been in weird edge cases where using something like hibernate SQL made my operation either untenable or computationally restrictive.

>youre an idiot
Eloquent. Do go on.

>its not a preference
MUH DOTS I NEEDS MUH DOTS REEEEEE

>readability of syntax
How the fuck does a $ impair the readability of PHP code? if anything, it makes it more readable.

PHP is a very interesting phenomenon.
It's a bad language. Badly designed, badly implemented. But it has HUGE support by both server companies, web space companies, library programmers and open source software. There is so fucking much written in PHP that's on the web you wouldn't believe it. And if something is widely supported then you can thank the fucking based community of volunteers and professionals to "save" the language. Same thing happened to C++.

tl;dr PHP itself is shit but the community made it great

youre trying to compare static compiled programming to dynamic languages where the meaning of an object is deeply overloaded with functionality, Im not going to waste my time explaining this to you, you C++ drones have already killed /dpt/, youve killed off any meaningful discussian about how functional programming is used and integrated in modern scripting languages, you deserve to continue to live in ignorance, Im not wasting my time on retards

And how does $ and . break dynamic typing for you in PHP?

I didnt say it broke it, it ruins readability, when youre dealing with deeply chained and overloaded objects, its important to see at a glance how it is wired up, arrow syntax is just clutter, again, as a basement dwelling fizzbuzzer I dont expect you to appreciate the importance of this

I dick around with a legacy cakePHP in house project, and it's really ugly when I have to dance around the ORM and deal with it returning tons of unnecessary crap and when it bogs the whole system down.

ORMs are great if you want to pull something up, fuck around with it and spit it out in JSON, and it's DB agnostic, which is awesome. But I hate it when people pretend that writing SQL is deprecated and ORMs are a magic bullet.

I've listened to an advocate of PostgreSQL on a podcast (of which name I can't remember now), and he stated that he frequently finds himself and his team pulling in tons of shit from the DB into his/their environment when he/they could have dealt with that data on the DB's side ages ago. I feels it.

>youre trying to compare static compiled programming to dynamic languages where the meaning of an object is deeply overloaded with functionality,
Yes, I get it. There's a reason C++ uses ->. But really, it's not an issue, you're just being a baby.

No, I'm not a C++ drone, I'm not from /dpt/, and please go back to writing Haskel code nobody will ever use in your special snowflake vim environment on your animu desktop.

I do enterprise service development for a 3 letter agency. I understand code readability and maintainability.

Code readability and maintainability always stems from little use of modularity, too much use of unnecessary abstraction, and too little use of clever abstraction (object hierarchy that knows something about its children and it self). While things like non-uniform indentation and bracket placement irk me and co-workers. It's not the worst thing in the world. Having to stare at code for 10 minutes longer to get the feel for it is not a lot of overhead.

However, if I can rewrite the thing from scratch using a different set of API, structures, patterns, etc in 1/5th of the time. Then there's a legitimate problem.

This is semi-topic

I'm slowly turning on to the idea of using embedded databases for when the server database is an unfriendly mess. Aside from one project, every task I've worked on has had a database that made our DBA's consider resignation. The amount of BS you have to go through to coerce some of these objects or queries to give you the data structured in a desired format is insane. If your use case is something that you must maintain structure I'm firmly of the belief that spooling up a small instance of Derby, h2 or sqlite is infinitely more productive and efficient than finagling a broken database into a new object hierarchy.

evertpot.com/PHP-Sucks/

nevermind the clickbait title.

thia triggers the NEET

Are we really discussing whether to or not to use language that 99% of internet is written on?

PHP will not die in the near future. Wether some shitty """"programmer"""" thinks its bad language or not is irrelevant like for any other language.
Especially the ones that holds the market.

Good luck with your performance, bro :(

>The problem I have with PHP has nothing to do with the language, it’s its reputation. I can’t count the times I’ve started a conversation with a programmer who upon finding out I primarily do PHP got awkward with me.
"I'm a hipster who has to fish for compliments by others in order to do my job"

What bootybombards the programming communtiy about PHP is just how messy and inelegant a tool it is. newcomer friendly and immediately usable, but at the cost of a whole fucking lot.

its very inconsistent

Python+Django is much better than PHP

Go.

The con is that even though the language has improved dramatically nobody cares. No new projects are being launched in PHP, nearly all PHP developers are paid less than their counterparts in other languages because they are respected less and thought of as unintelligent because of how PHP is thought of in the community. By the time you are good enough to get one of the few PHP jobs that pays a normal rate you'll be stuck with maintenance projects since you know theres no new projects being done in PHP.

Pros:
You can get a job after 2 weeks of study

Cons:
Awful syntax and full of quirks.
Doesn't enhance your epen0r and every other web developer and programmer will look down on you

>pros
lets you do anything you want
a n y t h i n g
Absolute madness language

>cons
let's others do anything they want and you'll have to fix their garbage

+1

Thanks for this, especially the last sentence.

ITT: People bitching about PHP on a website made in PHP.

"Pros":
Installed everytwhere

Contra:
Everything

One of the comfiest, maybe.
But damn is it dog slow. The zend engine does not take abstraction well. Any function call, any class, any interface or trait has a rather enormous cost.

The author literally said he has no idea how to develop a programming language. He just reboots until it works

>look mom I posted the copy pasta that pretends to make a point but doesn't again!

>Use that thing that literally no hosting service supports instead

Can you stop

>PHP also made a lot of stupid syntatic design choices like forcing $ in front of variables even outside of strings
That's because every variable is a string.

You're doing backend web development, not rendering high-resolution vectors with special effects. Just be happy it lets you perform perform math operations on strings and shut up.

>Anyone who who writes SQL queries by hand as part of their backend code is a complete idiot.

VPS 2hard4u?

>That's because every variable is a string.
Seriously? The fuck.

What if my backend is supposed to render high resolution vectors? What if it's supposed to do something more than DB queries and string concatenation?

This.

>Seriously? The fuck.
>What if my backend is supposed to render high resolution vectors? What if it's supposed to do something more than DB queries and string concatenation?

Even if PHP didn't use strings for all variables, you wouldn't want to use PHP to do anything like that because it's scripts ran by am interpreter.

If your back end is mainly PHP but you need to do image processing, you can use binary libraries from your PHP scripts, such as ImageMagick.

If it's just calling external binaries, might as well use a better language, because anything can do that. There's no reason to use PHP for anything, really. Only people using PHP are ones with no choice and ones too Pajeet to learn a better language.

PHP is extemely convenient for web programming. It was made especially for that. There is no reason to deal with a more complex and general purpose language if your objective is to make a webpage.

>I'm a college kid who has never worked that thinks that networking is totally unimportant to career advancement

And Java was also a lot more convenient than all alternatives once upon a time. Java is a general purpose language, so I take it you support writing everything in Java even today? Same thing with COBOL? Believe it or not, there are simple enough solutions today that actually have more than 2 seconds of thought put into their design.

Python.

IMO, no language is good or bad. its the pajeet who is good or bad. PHP was a cool option few years ago.

But com'on, it's 2016, use something more mature and not restricted to a web. Go for python, ruby, node etc.

Say, for some reasons, if you decide to go with PHP, never ever write the whole project with pure PHP (without any framework). Select a well implemented and secure web framework.

Also, only a idiot would implement his own SQL queries/ crypto etc. Leave that nightmare to experts if you don't know what you're doing.

Javascript is as bad as PHP, I hate how lazy web devs are trying to take it offline. Seriously it took 20 years to get let

>use something more mature and not restricted to a web
>to make a website
for_what_purpose.ai

It's literally just a meme to hate it

Backend?

You probably have never coded in you life.

There are languages unfit for a certain purpose. Brainfuck and Assembly are a bad choice for webdev and so is PHP.

Using a language that is good at something beside spitting out text is bad?

No, because "everything" may require qualities that Java doesn't have. But a webpage rarely needs anything that PHP can not do.

COBOL is not convenient for any purpose whatsoever.

You have to understand that a webpage is an HTML document. That's a very long string of text. A PHP application takes your request, finds the necessary information, parses it and spits out a plain text file. This is a simple task and should require simple tools.

What you're pushing for is comparable to eliminating shell scripting because of the perks of PERL.

If it makes you spend more time to get the same results, then yes. PHP allows you to skip a lot of the low-level stuff and that is valuable.

Is types other than string a very low level concept?

>tfw I want to use PHP7 but html purifier and paesedown don't fully support it.
when I do switch over is there anything I need to keep in mind?

>COBOL is not convenient for any purpose whatsoever.
Same as PHP then.

>A PHP application takes your request, finds the necessary information, parses it and spits out a plain text file
Which is terrible for any task that requires any kind of scaling.

>What you're pushing for is comparable to eliminating shell scripting because of the perks of PERL.
No, what I'm pushing for is use of better web scripting languages. Python and even JS are both better solutions in the script department.

If you get into the specifics, limitations and resource usage of every different type, kinda?

Websites are now heavily evolved. If you just need a non-sense CRUD website, sure, go with PHP.

But if you want to do. say, video chat app with some sort of compression tech which makes it the next-big-thing, Then you might want to reconsider.

>>COBOL is not convenient for any purpose whatsoever.
>Same as PHP then.
Okay, you can't just say random stuff and expect it to be an argument. It has to make some kind of sense.

>Which is terrible for any task that requires any kind of scaling
No web programming language is good at scaling because they are all interpreted languages. You have to use binaries to do that regardless of if you use Python, node.js or PHP.

PHP can't be used for encoding a closed circuit video stream over the web.

By the time you've figured out how to even do that, you're a little beyond using a high-level scripting language for convenience.

Let the holy war of programming languages begin.

Makes perfect sense. PHP is so shit it's not fit for the very purpose it was designed for. More so it was conceived as a "non-programming language", as Rasmus himself described it.

Go compiles to machine code and was designed mainly for writing web servers :^)

PHP wasn't designed for scaling in the first place?

I have another terrible epiphany for you: The web wasn't designed to code applications in it.

PHP was not designed for programmers at all. It was designed for college/high school kids with no IT background to let them create web pages easily.

Sadly so, but why make it any worse?

>using the smiley with a carat nose

...

>Pros

-A lot of jobs
-Many projects and servers use it
-A lot of frameworks (i.e. Wordpress)
-Minimalisitc: You can just use it for the few functions where you need it and ignore the rest


>Cons

-Ugly langauge
-You need to know what you are doing, for example sanitizing all your functions


Basically:
Learn the fundamentals of PHP, than take a good (!) PHP framework like Laravel and avoid writing pure PHP.