Comment on 4chan hacked and taken offline. Hacker reopens /qa/ and leaks all admins emails.
ProtecyaTec@lemmy.world 3 days agoReally though, it doesn’t.
I absolutely hate the way 4chan formats their HTML + PHP intermingling in views. That’s not to say WordPress doesn’t do this as well, but oh man in a much better, cleaner, and more sparingly way. The 4chan imageboard view Github -> 4chan is absolute chaos. Why this wasn’t rewritten is beyond me. That’s just the first thing I see as I peruse the source, I can’t imagine it gets much better from here.
Realitaetsverlust@lemmy.zip 3 days ago
I don’t think we’re looking at the same source code. The first thing I see in wp-activate.php:
This isn’t better nor cleaner. This is a disaster. A function that stops PHP execution halfway-through, outputs some text and then restarts PHP execution? Hell, I’ve been in the PHP ecosystem for over a decade now and I didn’t even know this was possible and I wish that knowledge was still hidden from me.
Maybe I was wrong by saying that the 4chan source code is better than wordpress, fair. Maybe I should just say both are abominations, I will not judge which one is better and both should be discarded and forgotten.
bufalo1973@lemm.ee 2 days ago
This has been possible since the very beginning of PHP.
I won’t say if this is the best way now. I haven’t touch PHP in the last 2 decades.
ProtecyaTec@lemmy.world 2 days ago
I completely disagree.
Intermingling PHP and HTML is one of PHP strengths. The processing/executing difference you’re describing is almost always negligible due to how PHP is optimized (specifically for this kind of thing).
Seriously, compare this to the 4chan image board view linked above, we really aren’t looking at the same source code. In comparison, this is blocked, purposeful, together. It’s a single CSS block output all at once. On the otherhand, in the linked 4chan discussion board PHP file, it echos as strings, broken up by multiple conditionals, and difficult from an IDE perspective to tell where a block starts and where it ends (again due to it being echo’d in strings, and broken by conditionals). Trying to modify this blocked CSS is going to be wayyyyyyyyyyyyyyyyyyyy easier than trying to modify a bunch of printed HTML strings broken up by multiple nested conditionals. Plus it’s just straight-up easier to read and straight-forward to understand what the function does right away.
I can’t think of a single system that doesn’t “stop PHP executing” at some point to output HTML in some way. Maybe an app that dynamically pulls it’s views in through JS I guess.
Realitaetsverlust@lemmy.zip 1 day ago
Eeeh, no. It’s a bad practice in 2025. That was a good thing a decade ago.
True. But I was just looking at the source code of wordpress for 30 seconds. I could probably find worse.
Which isn’t a problem if you use a template engine - as you should in modern applications.
Not a single modern system does that. It’s terrible practice and won’t even pass automated code reviews with sane settings.
ProtecyaTec@lemmy.world 1 day ago
What you’re talking about is semantics. At a base level, whether you use a templating engine, include / require, or just straight up mix HTML / PHP - PHP “stops execution” to output to the browser.
Templating engines are cool, and they make it easier to separate your views from logic, it makes interloping more straight-forward and possibly more maintainable, but I do not agree that it’s defacto. I think the strength of PHP is it’s ease to just jump into it and get something working, right “out of the box”. The ease of mixing PHP and HTML is a boon from an entry level aspect. Easy entry level leads to wider adoption.
I could create a vanilla PHP application that organizes views just as well without a templating engine which could be understood by someone with baseline PHP knowledge - that’s good thing. It’s inherit to PHP and I won’t need to worry about keeping an templating library updated or ported to we new engine.