I agree. There's nothing bad about the syntax. True, the language could be better. There are 99 reasons to dislike PHP but syntax is definitely not one of them.
Jeroen is a Software Craftsmanship advocate with over 15 years of experience. He is CEO of https://pro.wiki. Previously Jeroen created Wikidata.org and was Software Architect at Wikimedia Deutschland.
Haha, I can understand that. I actually liked the namespacing so much, I wrote a babel plugin that rewrites import paths in JS to work similarly. Not EXACTLY the same, but it's very similar.
I've been a professional C, Perl, PHP and Python developer.
I'm an ex-sysadmin from the late 20th century.
These days I do more Javascript and CSS and whatnot, and promote UX and accessibility.
PHP: it’s not a bad syntax, it’s just not what some people like, and they’ve formed opinionated debates over it.
I agree. There's nothing bad about the syntax. True, the language could be better. There are 99 reasons to dislike PHP but syntax is definitely not one of them.
PHP has been my main language for 10 years.
-> instead of . is rather unfortunate. Much harder to type :/
$var instead of var is also not idea if you ask me, though at least not as silly as needing to hit 3 keys.
That does not make the syntax as a whole ugly though.
Lol. It helps. :D
True enough. The syntax isn't bad as in defective or overly verbose. It does look inelegant to me, though.
Especially if you look at more modern PHP. I really like Laravel's code style.
For non-PHP developers, a few syntax niceties:
$
prefix. So$post = getPost($id)
.$request->has('name')
::
(by far my favorite).Route::get('/api/posts', function() {});
I also like PHP namespacing:
and accessing the namespace:
As someone who's used PHP in the past, all of your niceties are among the many reasons I don't care for the language 😆 to each their own though! 🤷🏻♂️
Haha, I can understand that. I actually liked the namespacing so much, I wrote a babel plugin that rewrites import paths in JS to work similarly. Not EXACTLY the same, but it's very similar.
I really dislike PHP namespacing.