Revision 303337376165 () - Diff

Link to this snippet: https://friendpaste.com/3ulifsCR1vBTAcTcAXqRId
Embed:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// Pointless commenting example:
// ----------
$username = mysql_real_escape_string($_POST['username']); # Get username
$password = mysql_real_escape_string($_POST['password']); # Get password
$age = intval($_POST['age')]; #Get age
// ----------

// The above is useless because it's quite obvious of what's happening.

// Useful commenting:
// ----------
# Get information from POST

$username = mysql_real_escape_string($_POST['username']);
$password = mysql_real_escape_string($_POST['password']);
$age = intval($_POST['age')];
// ----------

// This way saves time.

// Also, a good place to put comments, is when you're making a new function or class.
// Describe the inputs and outputs a bit.
// ----------

/*
Function: salt_crypt
Desc: Encrypts a string using a salt.
Inputs:
$string (string): The string to be encrypted
$salt (string) : The salt to use.
*/

function salt_crypt($string, $salt)
{
$return = md5(md5($string) . $salt);
return($return);
}

// ----------

/*

Why comment like that at the beginning of a function? It will save a lot of time. Saves the person reading from having to go through the code for that function.

*/