嗨,我正在尝试做一件奇怪的事情,我想将我所有网站页面的所有代码都放在if中,例如,我想这样做:
<?php
include('..../...../php/secure-open.php');
if(......){
ALL OF WEBSITE CODE HERE
include('..../...../php/secure-close.php');
}
其中secure-open.php是:
<?php
if(security check here){
?>
secure-close.php是
<?php
}else{
die();
}
?>
因此,只有在安全性条件为真的情况下,所有遗嘱才会被执行,但是当我尝试执行此操作时,它会说,意外的文档以行结尾。
答案 0 :(得分:1)
好像您错过了右括号:)
您确实不应该以这种方式解决安全检查,但是如果您确实确定需要这样做,请将“所有网站代码”移至其他文件,然后将其包含在if中。
def countfrequncyinarray(arr1):
r=len(arr1)
return {i:arr1.count(i) for i in range(1,r+1)}
arr1=[4,4,4,4]
a=countfrequncyinarray(arr1)
print(a)
还有一个易于实现的快速检查:
index.php:
if(security_check) {
include "website.php";
} else {
die();
}
website.php:
if (security_check) {
define('SECURE', true);
}
require "website.php";