PHP if statment question
I have a simple question. So I have this code in my php file:
if(empty($_POST['height'])) {
$width = '385';
}
is it possible to do something like this?
if value of ($_POST['height'开发者_StackOverflow社区] is 'height' then $width ='385'; instead of if empty?
Do you mean;
if (!empty($_POST['height']) && $_POST['height'] == 'height') {
$width = '385';
}
Update
Based on the comment, the solution would be:
if (array_key_exists('height', $_POST) && $_POST['height'] == 'height') {
$width = '385';
}
精彩评论