PHP “php://input” vs $_POST

The reason is that php://input returns all the raw data after the HTTP-headers of the request, regardless of the content type. The PHP superglobal $_POST, only is supposed to wrap data that is either application/x-www-form-urlencoded (standard content type for simple form-posts) or multipart/form-data (mostly used for file uploads) This is because these are the only … Read more

Disadvantages of scanf

Most of the answers so far seem to focus on the string buffer overflow issue. In reality, the format specifiers that can be used with scanf functions support explicit field width setting, which limit the maximum size of the input and prevent buffer overflow. This renders the popular accusations of string-buffer overflow dangers present in … Read more

How to delete a specific line in a file?

First, open the file and get all your lines from the file. Then reopen the file in write mode and write your lines back, except for the line you want to delete: with open(“yourfile.txt”, “r”) as f: lines = f.readlines() with open(“yourfile.txt”, “w”) as f: for line in lines: if line.strip(“\n”) != “nickname_to_delete”: f.write(line) You … Read more

How to get the user input in Java?

You can use any of the following options based on the requirements. Scanner class import java.util.Scanner; //… Scanner scan = new Scanner(System.in); String s = scan.next(); int i = scan.nextInt(); BufferedReader and InputStreamReader classes import java.io.BufferedReader; import java.io.InputStreamReader; //… BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String s = br.readLine(); int i = Integer.parseInt(s); DataInputStream class … Read more