3ulifsCR1vBTAcTcAXqRId changeset

Changeset303337376165 (b)
ParentNone (a)
ab
0+// Pointless commenting example:
0+// ----------
0+$username    = mysql_real_escape_string($_POST['username']); # Get username
0+$password    = mysql_real_escape_string($_POST['password']); # Get password
0+$age         = intval($_POST['age')];  #Get age
0+// ----------
0+
0+// The above is useless because it's quite obvious of what's happening.
0+
0+// Useful commenting:
0+// ----------
0+# Get information from POST
0+
0+$username    = mysql_real_escape_string($_POST['username']);
0+$password    = mysql_real_escape_string($_POST['password']);
0+$age         = intval($_POST['age')];
0+// ----------
0+
0+// This way saves time.
0+
0+// Also, a good place to put comments, is when you're making a new function or class.
0+// Describe the inputs and outputs a bit.
0+// ----------
0+
0+/*
0+    Function: salt_crypt
0+    Desc: Encrypts a string using a salt.
0+    Inputs:
0+        $string (string): The string to be encrypted
0+        $salt (string)  : The salt to use.
0+*/
0+
0+function salt_crypt($string, $salt)
0+{
0+    $return = md5(md5($string) . $salt);
0+    return($return);
0+}
0+
0+// ----------
0+
0+/*
0+
0+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.
0+
0+*/
...
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
46
47
48
--- Revision None
+++ Revision 303337376165
@@ -0,0 +1,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.
+
+*/