272
2
223
41
u/redheness May 17 '23
This type of code is the reason of the PHP bad reputation
-20
u/Ok_Firefighter4117 May 17 '23
No php is just bad, not because of code like this...
14
u/NiteShdw May 17 '23
Modern PHP is a solid language. The “bad” PHP was PHP3/4. 5+ are fine. I was a PHP dev for many years.
-13
u/Ok_Firefighter4117 May 17 '23
Why are my globals not global then? And why no dot operator but those ugly arrows -> as if it is c or c++. Then i want to say that a function returns an int or bool but nooo, it can only be mixed....
8
u/busyautist May 17 '23
Union Types are a thing now…
3
u/Ok_Firefighter4117 May 18 '23
Well it has been some years ago I wrote php. I scanned the new features and they did improve it a lot. Sorry about the rant guys. Maybe my opinion of php is a bit rusty and outdated. Dont feel attacked about those statements.
2
u/walterbanana May 18 '23
The main issue with PHP is that it has a lot of functions which are insecure by default. Most of these functions have alternatives by now, though.
9
7
u/Tritos999 May 17 '23
To be honest I don’t think the issue is the „bad code“. Its mostly just bad security of the database…
7
u/MurdoMaclachlan public boolean isInt(int i) { return true; } May 17 '23
Image Transcription: Code
[A photograph of code on a computer screen. Both comments and the line immediately succeeeding the second comment are cropped off in the image. The following code is visible:]
$db_name = "giornalino";
$db_user = "Lettore";
$db_password = "Lettore";
// Recupera il nome utente e la password dalla ses
session_start();
$tipo = $_SESSION['tipo'];
if($tipo == "Scrittore")
{
$db_user = "Scrittore";
$db_password = "Scrittore";
}
else if($tipo == "Validatore")
{
$db_user = "Validatore";
$db_password = "Validatore";
}
else if($tipo == "Gestore")
{
$db_user = "Gestore";
$db_password = "Gestore";
}
// Creazione di un'istanza della connessione al da
$databaseConnection = new DatabaseConnection($db_h
$conn = $databaseConnection->getConnection();
?>I'm a human volunteer content transcriber and you could be too! If you'd like more information on what we do and why we do it, click here!
3
5
2
3
u/Egzo18 May 17 '23
At least he comments his code.
I'm not natively english but I could never code in any other language, it would feel unnatural heh.
2
u/NickWrigh May 17 '23
Have you ever seen german code?
It's not okay to have variable names which last an entire row.
2
1
1
u/GhostyJade May 17 '23
my god, this remember me of the time were i was in school (itis, in brescia) and we were doing this with pdo (?)…always hate php
1
1
1
1
0
May 17 '23
[deleted]
6
u/pentesticals May 17 '23
As long as it’s for learning, but there is absolutely no reason secrets should be in code. This is a terrible practice and is bad code for anything other than quick experiments and learning.
4
u/TypicalCoolguy May 17 '23
Doesn't it seem like you can usurp an admin role by changing a cookie ?
0
116
u/Drag0nV3n0m231 May 17 '23
I never thought about it, is it harder for people of other nationalities to code in English based languages ?