以下是我写的函数和我使用的丑陋注释。你会使用哪种方式来注释代码?
//function to check if the uploaded Image is valid
function valid_image($image, $target, $url, $width, $height = 0) {
//Check if the uploaded image is of type jpeg
//if not then pop up a warning message and return false and redirect back
if( $image["type"] !== "image/jpeg") {
alert('File must be of type image/jpeg');
redirect_url($url);
return false;
}
//Check the file Dimension of the Uploaded Image if it matches with the defined Value
//Get the Dimensions of the image
list($image_width, $image_height) = getimagesize($image['tmp_name']);
//If the Parameter Height is empty then just check the image width and ignore the height rule
//Print the appropriate message and return false and redirect back
if( $height == '0') {
if( $image_width !== $width) {
alert("Incorrect File Dimension for " . $image['name'] . " Please make sure it is $width in width");
redirect_url($url);
return false;
}
}
//If the function has got all the parameter then check both the defined height and width
//Print the appropriate message and return false and redirect back
else if($image_width !== $width || $image_height !== $height) {
alert("Incorrect File Dimension for " . $image['name'] . " Please make sure it is $width X $height ");
redirect_url($url);
return false;
}
return true;
}
Thanks in Advance.