This is not about how you make the code right or false. Actualy there is no code are wrong. There is an incorect code and logic. Is not simple to fix the incorect logic, but with good style and understanding your own code, we can fix it.
When I requested to become teacher from PHP code, I try to avoid give the student my style. The first things I should teach was why the style to be like that. for example:
if your gender are female, show female or show malein PHP code you can type this
$gender=='F'?echo 'Female':echo 'Male';or
if($gender=='F')or
echo 'Female';
else
echo 'Male';
if($gender=='F'){all code are true, but the style are different. Basicly the important from all code you make is the note! If you type a long code but you don't give a note for what the code for.. Is not good, the reason if you found error (on logic), you can fix it more fast.
echo 'Female';
}else{
echo 'Male';
}
In the end, I hope you can make script like this
include with notes.
/* CHECK GENDER */
if($gender=='F')
{
echo 'Female';
}else{
echo 'Male';
}
/*END CHECK GENDER*/
but you need to focus on your own style. If you don't have the style.. Mimic other, but remember to give notes. Is better leave a notes on you code to debug you script in the future.
0 comments:
Post a Comment