SEARCH
0-9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Prev | Current Page 115 | Next

Hasin Hayder

"Object-Oriented Programming with PHP5"


Ensures the workability of your complete application after any kind
of refactoring.
Checks the redundancy and removes them from your code.
Designs good API.
Easily figures out where the problem is.
Speeds up the debugging process if anything goes wrong; as you know
particularly where the bug resides.
Minimizes the effort of documentation by providing working examples of
your API.
Helps to do a regression test so that no regression occurs again.
A small Introduction to Vulnerable Bugs
Bugs can be of different types. Some bugs could just bother your users, some bug
stops the functionality, and some bug vulnerability corrupts your resources. Let
us consider the following example. You have written a function which takes two
parameters and updates the database accordingly. The first parameter is the name of
the field and the second parameter is the value of that field by which it should locate
the data and then update them. Now let us design it:
function selectUser($field, $condition)
{
if (!empty($condition))
{
$query = "{$field}= '{$condition}'";
}
else
$query = "{$field}";
echo "select * from users where {$query}";
$result = mysql_query("select * from users where {$query}");
$results = array();
while ($data = mysql_fetch_array($result))
{
$results[] = $data;
}
return $results;
}
??? ??? ??? ??? ??? ??? ??? ???
Reflection and Unit Testing
[ 112 ]
Now when you call it like this, it shows a specific data:
print_r(selectUser("id","1");
The output is:
(
[0] => Array
(
[0] => 1
[id] => 1
[1] => afif
[name] => afif
[2] => 47bce5c74f589f4867dbd57e9ca9f808
[pass] => 47bce5c74f589f4867dbd57e9ca9f808
)
)
But when you call it like this:
print_r(selectUser("id",$_SESSION['id']);
It displays the following:
(
[0] => Array
(
[0] => 1
[id] => 1
[1] => afif
[name] => afif
[2] => 47bce5c74f589f4867dbd57e9ca9f808
[pass] => 47bce5c74f589f4867dbd57e9ca9f808
)
1] => Array
(
[0] => 2
[id] => 2
[1] => 4b8ed057e4f0960d8413e37060d4c175
[name] => 4b8ed057e4f0960d8413e37060d4c175
[2] => 74b87337454200d4d33f80c4663dc5e5
[pass] => 74b87337454200d4d33f80c4663dc5e5
)
)
This is not a correct output; and as it is happening in runtime if it was update instead
of a select query, your whole data may get corrupt.


Pages:
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127
hotel jelenia góra Russian bride Free English grammar and study guid powiekszenia wielkoformatowe counter strike 1.6