我在IntelliJ中将PEP8缩进设置为2。但是,我仍然得到PEP8压痕警告,因为长度不是4。我去了'设置 - >编辑 - > Python'并关闭缩进警告。但是,检查员仍然继续给我警告。
答案 0 :(得分:7)
转到E111
并将<?php
$conn = new mysqli("localhost","root","","noti");
$count=0;
if(!empty($_POST['add'])) {
$subject = mysqli_real_escape_string($conn,$_POST["subject"]);
$comment = mysqli_real_escape_string($conn,$_POST["comment"]);
$sql = "INSERT INTO comments (subject,comment) VALUES('" . $subject . "','" . $comment . "')";
mysqli_query($conn, $sql);
}
$sql2="SELECT * FROM comments WHERE status = 0";
$result=mysqli_query($conn, $sql2);
$count=mysqli_num_rows($result);
?>
<html>
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Facebook Like Header Notification in PHP</title>
<link rel="stylesheet" href="css/font-awesome.min.css" />
<link rel="stylesheet" href="assets/css/main.css" />
<link rel="stylesheet" href="https://noraesae.github.io/perfect-scrollbar/perfect-scrollbar.min.css" />
<link href='https://fonts.googleapis.com/css?family=Source+Sans+Pro:400,600' rel='stylesheet' type='text/css'>
<style>
*, *:before, *:after {
box-sizing: border-box;
}
body {
font-family: "Source Sans Pro", sans-serif;
background: #FAFAFA;
}
#main-header {
height: 63px;
background: #3D4752;
text-align: center;
padding: 20px 0;
}
#bell {
position: relative;
display: inline-block;
}
#bell svg {
cursor: pointer;
}
#bell .bubble {
position: absolute;
bottom: -3px;
left: 10px;
min-width: 16px;
height: 16px;
border-radius: 999px;
background: #29AAE1;
color: #fff;
font-size: 14px;
text-align: center;
padding: 0 3px;
cursor: pointer;
}
.noti-container {
position: absolute;
top: 30px;
width: 300px;
height: auto;
min-height: 175px;
max-height: 700px;
left: -147px;
background: #fff;
border-radius: 4px;
box-shadow: 0 3px 10px rgba(0, 0, 0, 0.4);
text-align: left;
display: none;
-webkit-transition: top 0.5s;
transition: top 0.5s;
}
.noti-container header {
background: #707E8D;
padding: 16px;
border-radius: 4px 4px 0 0;
}
.noti-container header h3 {
font-weight: 600;
color: #fff;
display: inline-block;
}
.noti-container header a {
float: right;
text-decoration: none;
color: #fff;
font-size: 14px;
}
.noti-container:before {
width: 0;
height: 0;
content: "";
border-right: 15px solid transparent;
border-bottom: 15px solid #707E8D;
border-left: 15px solid transparent;
position: absolute;
top: -15px;
right: 130px;
}
.noti-container h2 {
font-weight: 600;
color: #a0a0a0;
text-align: center;
margin-top: 50px;
display: none;
}
.noti-container ul {
max-height: 342px;
overflow-y: scroll;
position: relative;
}
.noti-container ul li {
padding: 10px;
color: #5a5a5a;
border-bottom: 1px solid #E6E6E6;
position: relative;
font-size: 14px;
list-style:none;
}
.noti-container ul li h4 {
margin-bottom: 4px;
font-weight: 600;
}
.noti-container ul li p {
line-height: 1.4;
}
.noti-container ul li a {
text-decoration: none;
color: #29AAE1;
}
.noti-container ul li a:hover {
text-decoration: underline;
}
.noti-container ul li .time, .noti-container ul li .clear {
position: absolute;
top: 15px;
right: 15px;
color: #A0A0A0;
font-size: 12px;
opacity: 1;
-webkit-transition: opacity 0.25s;
transition: opacity 0.25s;
}
.noti-container ul li .clear {
opacity: 0;
-webkit-transition: opacity 0.25s;
transition: opacity 0.25s;
cursor: pointer;
}
.noti-container ul li.unread .time, .noti-container ul li.unread .clear {
margin-right: 12px;
}
.noti-container ul li.unread .time:after, .noti-container ul li.unread .clear:after {
content: "";
width: 8px;
height: 8px;
background: #29AAE1;
position: absolute;
top: 2px;
right: -12px;
border-radius: 999px;
}
.noti-container ul li:hover .time {
opacity: 0;
}
.noti-container ul li:hover .clear {
opacity: 1;
}
.shadow-wrapper {
width: 100%;
height: 20px;
position: absolute;
bottom: 0;
right: 0;
border-radius: 0 0 4px 4px;
background-image: url("https://i.imgur.com/pMF6Mom.png");
background-repeat: repeat-x;
background-position: bottom center;
background-size: contain;
}
.button-default {
-webkit-transition: 0.25s ease-out 0.1s color;
-moz-transition: 0.25s ease-out 0.1s color;
-o-transition: 0.25s ease-out 0.1s color;
transition: 0.25s ease-out 0.1s color;
background: transparent;
border: none;
cursor: pointer;
margin: 0;
outline: none;
position: relative;
}
.show-notifications .notifications-count {
-moz-border-radius: 50%;
-webkit-border-radius: 50%;
border-radius: 50%;
-moz-background-clip: padding-box;
-webkit-background-clip: padding-box;
background-clip: padding-box;
background: #3498db;
color: #fefefe;
font: normal 0.85em 'Lato';
height: 16px;
line-height: 1.75em;
position: absolute;
right: 2px;
text-align: center;
top: -2px;
width: 16px;
}
</style>
<script src="https://code.jquery.com/jquery-2.1.1.min.js" type="text/javascript"></script>
<script type="text/javascript">
function myFunction() {
$.ajax({
url: "view_notification.php",
type: "POST",
processData:false,
success: function(data){
$("#notification-count").remove();
$("#notification-latest").show();
$("#list").html(data);
},
error: function(){}
});
}
</script>
</head>
<body>
<header id="main-header">
<div id="bell">
<button type="button" class="button-default show-notifications active js-show-notifications" onclick="myFunction()">
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="30" height="32" viewBox="0 0 30 32">
<defs>
<g id="icon-bell">
<path class="path1" d="M15.143 30.286q0-0.286-0.286-0.286-1.054 0-1.813-0.759t-0.759-1.813q0-0.286-0.286-0.286t-0.286 0.286q0 1.304 0.92 2.223t2.223 0.92q0.286 0 0.286-0.286zM3.268 25.143h23.179q-2.929-3.232-4.402-7.348t-1.473-8.652q0-4.571-5.714-4.571t-5.714 4.571q0 4.536-1.473 8.652t-4.402 7.348zM29.714 25.143q0 0.929-0.679 1.607t-1.607 0.679h-8q0 1.893-1.339 3.232t-3.232 1.339-3.232-1.339-1.339-3.232h-8q-0.929 0-1.607-0.679t-0.679-1.607q3.393-2.875 5.125-7.098t1.732-8.902q0-2.946 1.714-4.679t4.714-2.089q-0.143-0.321-0.143-0.661 0-0.714 0.5-1.214t1.214-0.5 1.214 0.5 0.5 1.214q0 0.339-0.143 0.661 3 0.357 4.714 2.089t1.714 4.679q0 4.679 1.732 8.902t5.125 7.098z" />
</g>
</defs>
<g fill="#000000">
<use xlink:href="#icon-bell" transform="translate(0 0)"></use>
</g>
</svg>
<div class="notifications-count js-count" id="notification-count"><?php if($count>0) { echo $count; } ?></div>
</button>
<div class="noti-container" id="notification-latest">
<header>
<h3>Notifications</h3><a id="clearAll" href="#">Clear All</a>
</header>
<h2>No new notifications</h2>
<ul id="list">
</ul>
<div class="shadow-wrapper"></div>
</div>
</div>
</header>
<?php if(isset($message)) { ?> <div class="error"><?php echo $message; ?></div> <?php } ?>
<?php if(isset($success)) { ?> <div class="success"><?php echo $success;?></div> <?php } ?>
<form name="frmNotification" id="frmNotification" action="" method="post" >
<div id="form-header" class="form-row">Add New Message</div>
<div class="form-row">
<div class="form-label">Subject:</div><div class="error" id="subject"></div>
<div class="form-element">
<input type="text" name="subject" id="subject" required>
</div>
</div>
<div class="form-row">
<div class="form-label">Comment:</div><div class="error" id="comment"></div>
<div class="form-element">
<textarea rows="4" cols="30" name="comment" id="comment"></textarea>
</div>
</div>
<div class="form-row">
<div class="form-element">
<input type="submit" name="add" id="btn-send" value="Submit">
</div>
</div>
</form>
<script src="assets/js/jquery.min.js"></script>
<script>
var bell = $('#bell');
var clearBtn = $('.clear');
var unread = $('.unread').length;
var listLength = $('li').length;
var bubble = $('.bubble');
var container = $('.noti-container');
bell.click(function(e) {
if( container.is(":hidden") ){
container.fadeIn(300).css('top', '50px');
} else {
container.fadeOut(300).css('top', '30px');
}
e.stopPropagation();
});
clearBtn.click(function(e) { // not working
listItem = $(this).parents('li');
if (listItem.hasClass('unread')) {
unread --;
}
listLength --;
$(this).parents('li').slideUp(300);
e.stopPropagation();
});
$('#clearAll').click(function(e) { //working
$('li').slideUp(300);
unread = 0;
listLength = 0;
counter();
e.stopPropagation();
});
$(document).click(function() {
container.fadeOut(300).css('top', '30px');
});
container.click(function(e){
e.stopPropagation();
});
</script>
</body>
</html>
添加到&#34;忽略错误&#34;列表。