/php/ General

Why do Sup Forums think of this?

Other urls found in this thread:

packagist.org/packages/symfony/var-dumper).
gist.github.com/Zenexer/40d02da5e07f151adeaeeaa11af9ab36
github.com/AmmarkoV/AmmarServer
twitter.com/NSFWRedditGif

shit lang

Mods love it

Just learn Python/flask

but we dont

If PHP is so bad, why is it so ubiquitous?

I like earning money.

>Wrong post
Fucking retard, check the post numbers fucking mong.

It's great for writing the occasional small web app or using it as glue between systems which don't use PHP.

I like PHP, I even use it in JavaScript and CSS and now with version 7 it’s really fast.

Just because it is ubiquitous, doesn't mean its good. It only became popular in the 90s because it allowed easy creation of backend, despite being better alternatives. PHP wasn't even supposed to be designed as a language, it started out as a bunch of tools some guy wrote in C for his web page. Eventually he added more extensions, he didn't even know how to make a language as it wasn't his goal to make a new programming language. Eventually it evolved to the turd it is today. I mean even its early hash was just strlen and many of the functions have inconsistent names and function arguments have inconsistent ordering because they were wrappers around C functions. The language as a result is poorly thought out and lacks any consistency. There are just so many better alternatives nowadays that nobody sane would start a new project in PHP.

>t. PHP developer

Is it worth it to learn PHP if I want to get a job, or would I be better off with another language? What are the alternatives? I know of Python, Ruby, and NodeJS.

Depends where you live. You have to look at job ads and figure out what the popular language. For where I learn C# is popular. Also, knowing Javascript is always beneficial as it is the standard front end language.

Learn both. If you work at a web development company usually older systems may be in PHP and most small websites are using WordPress.

Then for new web apps they will be using any of those three you listed.

So PhP is good for getting a junior position. It's what I did and then I got trained in Ruby.

I love it

It's good if you do OOP, PHPTheRightWay and use Symfony/Laravel. It attracts a lot of shitheads that produce shit code though.

>It only became popular in the 90s [...] despite being better alternatives.
The only alternatives for dynamic web content back then were Perl or writing your own CGI tools in C (which is how PHP started, as you pointed out), neither of which was easier or better. PHP did an awful lot of things terribly wrong but it owes its popularity to two things it did extremely right: shallow learning curve and ease of deployment.

>t. I made websites in the 90's

only thing i dislike about php are the nested arrays. nested multi dimensionals are hard to read

$arr1 = array(item1 => array (
item3a => array($item6, $item7)
))

Is there a way to make arrays in php easier to read?

unlike in javascript they are just brackets no matter how nested its still easy to read.

let items = [a, [b, c, d, e], f, g, {h: i, j: [k, l, m]}];

PHP has supported bracket notation for arrays / hashmaps for years:
$arr = ['foo', 'bar', ['baz' => 'foobar'], 'bazbar'];

deprecated

yeah but if you print/print_r an array its back to the same old unreadable shit.

Array
(
[0] => foo
[1] => bar
[2] => Array
(
[baz] => foobar
)

[3] => bazbar
)

Looks pretty readable to me. If you're one of those guys who "debugs" by print_r/var_dump-ing variables in the middle HTML, of course the browser is gonna ignore the whitespaces. Get a real debugger.

>backend

PHP is not backend. It's fullstack.
PHP is meant to be injected directly into HTML.

That's what makes it so great for small web sites and terrible for anything else.

Worthless. Node. Js is asynchronous

I love it. I think most people who are decent programmers respect the language. codebros just buy the hype. I use it as a litmus test.

this.

...

Are you saying procedural PHP is the best PHP?

Use something else

One company really insists that I learn PHP for some reason. They said they would add extra 100 monies to my internship salary if I did. My other alternative is .NET and Oracle internship in company that works for government or telecom company I worked for as an intern before. I kinda want to explore but I kinda liked working for telecom guys. What do?

php is a framework not a language

Horrible language, but thanks to composer and the mature ecosystem, it's surprisingly usable nowadays.

Just wish we had enums, a more complex type system that allows expressing things like function signatures, generics and better performance.

That or use symfony/debug's var dumper (packagist.org/packages/symfony/var-dumper).

> .NET and Oracle
Enterprise hell.
> PHP
Webdev hell.

Only really shitty websites combine php and html nowadays. That's an awful practice and needs to die.

Reasonable developers use proper templating languages like twig with PHP.

Inconsistencies everywhere
Lots of idiosyncrasies
Very easy to do something wrong and introduce vulnerabilities into your site
Not the language's fault but there are lots of very bad tutorials out there with unsafe/outdated advice

If you want into web development, learn php and javascript. Wordpress, Joomla, and Drupal use php. Literally everything uses javascript on the front-end. The amount of maintainable legacy code in php/ js will keep you employed for a lifetime.

Python is a general-purpose language. NodeJS is not a language and I wouldn't recommend jumping into it without knowing javascript. RoR I can't comment on but it seems quite nice.

>most small websites are using WordPress
most websites period tbqh

Yeah. I love many of the language's WTFs.
For example, do you know the constant to use to format a date using ISO 8601? \DateTime::ISO8601? Ha! No! That's a faulty format that doesn't correspond to any standard, the right constant would be \DateTime::ATOM.
It's not getting fixed. It's not getting deprecated. It's there, another hidden landmine waiting for PHP developers to stumble over it and unknowingly cause harm.

I also love how there's no function to exec a program with params safely. There's escapeshellarg and escapeshellcmd, and to be truly safe, you'd need to be use both of them on the string you want to execute - but if you do that, you open yourself up to even worse vulerabilities: gist.github.com/Zenexer/40d02da5e07f151adeaeeaa11af9ab36
Nope, those functions won't get fixed, they won't get deprecated, we'd rather have backwards compatible backdoor programs than to have to *gasp* have 10 year old code stop working!

The PHP core is full of idiotic quirks like that, they are everywhere, not a single core or extension feature can really be safely used. In order to properly use PHP, you need some massive abstractions like Symfony's libraries which re-implement the kinds of features PHP already has in a sane, but much worse performing manner.

Reasonable developers separate presentation from business logic, but using Twig and the likes is fucking retarded. PHP *is* a templating language. Having it interpret another templating langue, one with its own ugly-ass syntax (because you often still need some logic in the presentation, so it akwardly re-implements loops, conditionals etc.) but a fraction of expressive power and with considerable parsing overhead is idiotic.

>Reasonable developers separate presentation from business logic, but using Twig and the likes is fucking retarded. PHP *is* a templating language.

FUCK

ARE YOU ME

JUST YESTERDAY I HAD THE SAME CONVERSATION WITH A COLLEAGUE

Twig doesn't have parsing overhead because it uses PHP - the language is basically compiled into PHP code and that code gets executed instead.
Using PHP as a templating language just isn't okay anymore. It was revolutionary in the 90s, but now it just sucks at the job. First of all, every output is unsafe by default, which leads to the thousands of XSS exploits we have on the web.
Twig, in constrast, outputs every variable wrapped in in suitable escape function (htmlspecialchars with the proper charset for HTML, for example) by default - if you don't want it to be escaped, you have to tell it. That's a much safer and much more sane default.
Also, PHP doesn't have anything like template inheritance or blocks. To share a common base layout in PHP, you need to do some ugly hacks, while twig just does it right by default.
Twig is more than capable enough for handling pretty much everything you need to do in your view layer, and it's MUCH better than PHP at it.

PHP is bretty good..
Native C would be better though ;p
github.com/AmmarkoV/AmmarServer

Yeah, that's what I figured. The pay with telecom guys wasn't that great but I'm low maintenance guy and the job itself was comfty test automation.

In any ways, PHP is perfect for websites. It's not a programming language, it's only a scripting framework, not a bit more. Hence, it is retarded to treat it more than what it is. Websites are not programs, it only ran once, output the result of request query into HTML pages, and that's it. I never understand why would people—and ironically me since the industry dragged me into this path—make PHP behaves like a binary program with OOP and such. Muh abstraction. Muh encapsulation. Bleh. With this perspective, PHP is perfect for websites, so does Python but I never liked it.

I agree. PHP is really nice for small projects.

Php7 seems decent. It has traits, than opens new design possibilities. i will use it for my next project, just because of coders availability. If it were for me, i would just use Perl6 Cro library.

why is p6 webdev better than p5 webdev?

Go with .Net and Oracle if you don't want to be a smallfry forever

there's php frameworks, but no, php is the language

it's a framework because of superglobals, sessions, etc. being built in

at least it's not python that shits the bed if you put a space somewhere by accident and it's developers maintaining two versions one of which is a legacy version full of dead modules.