How do nested if nesting optimize the wording?
If conditions like this can be written again, should not use switch, after all, to determine the time, frequency, IP and other conditions.
If (access time period) {
echo "Normal time period";
if (ID range) {
echo "Normal ID range";
if (number of visits) {
echo "Normal access times";
if (IP address) {
echo "Normal IP Address";
}else{
echo "Error IP Address";
}
}else{
echo "Excessive number of visits";
}
}else{
echo "Error ID range";
}
}
else{
echo "Please take a rest";
}
------to solve the idea----------------------
The parallel notation
while (true) {
If (access time period) {
echo "Normal time period";
}else {
echo "Please take a rest";
Break
}
if (ID range) {
echo "Normal ID range";
}else {
echo "Error ID range";
Break
}
if (number of visits) {
echo "Normal access times";
}else {
echo "Excessive number of visits";
Break
}
if (IP address) {
echo "Normal IP Address";
}else{
echo "Error IP Address";
Break
}
Break
}
------to solve the idea----------------------
$error = 0;
If (access time period) {
echo "Normal time period";
else{
$error = 1;
echo "Please take a rest";
}
if ($error ==0 && ID range) {
echo "Normal ID range";
}else{
$error = 1;
echo "Error ID range";
}
if ($error ==0 && visits) {
echo "Normal access times";
}else{
$error = 1;
echo "Excessive number of visits";
}
if ($error ==0 && IP address) {
echo "Normal IP Address";
}else{
$error = 1;
echo "Error IP Address";
}