<?php class FileInfoTest extends PHPUnit_Framework_TestCase { protected $fileWithExtension; protected $fileWithoutExtension; public function setUp() { $this->fileWithExtension = new \Upload\FileInfo(dirname(__FILE__) . '/assets/foo.txt', 'foo.txt'); $this->fileWithoutExtension = new \Upload\FileInfo(dirname(__FILE__) . '/assets/foo_wo_ext', 'foo_wo_ext'); } public function testConstructor() { $this->assertAttributeEquals('foo', 'name', $this->fileWithExtension); $this->assertAttributeEquals('txt', 'extension', $this->fileWithExtension); $this->assertAttributeEquals('foo_wo_ext', 'name', $this->fileWithoutExtension); $this->assertAttributeEquals('', 'extension', $this->fileWithoutExtension); }
我们知道,在使用语言的过程中,肯定会关注在实际开发过程中的安全性问题。那么,今天我们就来为大家介绍保证PHP安全的首要措施——验证数据。数据的验证是您可能采用的最重要的习惯。而在提及输入时,十分简单:不要相信用户。在保证PHP安全而进行验证数据时,记住设计并验证应用程序允许使用的值通常比防止所有未知值更容易。
下面列出了适用于各种验证数据的一般验证提示:
1. 使用白名单中的值
2. 始终重新验证有限的选项
3. 使用内置转义函数
4. 验证正确的数据类型(如数字)
白名单中的值(White-listed value)是正确的值,与无效的黑名单值(Black-listed value)相对。两者之间的区别是,通常在进行验证数据时,可能值的列表或范围小于无效值的列表或范围,其中许多值可能是未知值或意外值。
本站所有资源均由网友贡献或各大下载网站转载。请自行检查软件的完整性!本站所有资源仅供学习参考。请不要将它们用于商业目的。否则,一切后果由您负责!如有侵权,请联系我们删除。联系方式:admin@php.cn
相关文章
21Oct2024
如何通过 PHP 上传视频文件并使用数据库条目将它们保存在适当的文件夹中简介要有效地管理网站上的视频上传,您需要实现一个系统,允许用户上传视频,将它们存储在有组织的文件中
12Dec2024
B站缓存视频可通过第三方工具提取,步骤如下:找到缓存视频文件(Windows:C:\Users\<用户名>\AppData\Roaming\bilibili\cache\video;Mac:/Users/<用户名>/Library/Caches/Bilibili/Video;Android:/storage/emulated/0/Android/data/tv.danmaku.bili/cache/video)使用第三方工具(如Bilibi
if($res){
return json_encode(array('code'=>1,'msg'=>'成功'));
}else{
return json_encode(array('code'=>0,'msg'=>'失败'));
}
}
public function
}
Call Stack
- in Index.php line 220
- at think\__include_file() in Loader.php line 85
- at Loader::autoload()
- at spl_autoload_call()
- at class_exists() in Loader.php line 478
- at Loader::controller() in App.php line 580
- at App::module() in App.php line 456
- at App::exec() in App.php line 139
- at App::run() in start.php line 19
- at require('/data/wwwroot/td.880...') in index.php line 23
Environment Variables
GET Data
Cookies
Server/Request Data
ThinkPHP Constants
23Nov2024
if($res){
return json_encode(array('code'=>1,'msg'=>'成功'));
}else{
return json_encode(array('code'=>0,'msg'=>'失败'));
}
}
public function
}
Call Stack
- in Index.php line 220
- at think\__include_file() in Loader.php line 85
- at Loader::autoload()
- at spl_autoload_call()
- at class_exists() in Loader.php line 478
- at Loader::controller() in App.php line 580
- at App::module() in App.php line 456
- at App::exec() in App.php line 139
- at App::run() in start.php line 19
- at require('/data/wwwroot/td.880...') in index.php line 23
Environment Variables
GET Data
Cookies
Server/Request Data
ThinkPHP Constants
if($res){
return json_encode(array('code'=>1,'msg'=>'成功'));
}else{
return json_encode(array('code'=>0,'msg'=>'失败'));
}
}
public function
}
Call Stack
- in Index.php line 220
- at think\__include_file() in Loader.php line 85
- at Loader::autoload()
- at spl_autoload_call()
- at class_exists() in Loader.php line 478
- at Loader::controller() in App.php line 580
- at App::module() in App.php line 456
- at App::exec() in App.php line 139
- at App::run() in start.php line 19
- at require('/data/wwwroot/td.880...') in index.php line 23
Environment Variables
GET Data
Cookies
Server/Request Data
ThinkPHP Constants
22Nov2024
if($res){
return json_encode(array('code'=>1,'msg'=>'成功'));
}else{
return json_encode(array('code'=>0,'msg'=>'失败'));
}
}
public function
}
Call Stack
- in Index.php line 220
- at think\__include_file() in Loader.php line 85
- at Loader::autoload()
- at spl_autoload_call()
- at class_exists() in Loader.php line 478
- at Loader::controller() in App.php line 580
- at App::module() in App.php line 456
- at App::exec() in App.php line 139
- at App::run() in start.php line 19
- at require('/data/wwwroot/td.880...') in index.php line 23
Environment Variables
GET Data
Cookies
Server/Request Data
ThinkPHP Constants
if($res){
return json_encode(array('code'=>1,'msg'=>'成功'));
}else{
return json_encode(array('code'=>0,'msg'=>'失败'));
}
}
public function
}
Call Stack
- in Index.php line 220
- at think\__include_file() in Loader.php line 85
- at Loader::autoload()
- at spl_autoload_call()
- at class_exists() in Loader.php line 478
- at Loader::controller() in App.php line 580
- at App::module() in App.php line 456
- at App::exec() in App.php line 139
- at App::run() in start.php line 19
- at require('/data/wwwroot/td.880...') in index.php line 23
Environment Variables
GET Data
Cookies
Server/Request Data
ThinkPHP Constants
23Nov2024
if($res){
return json_encode(array('code'=>1,'msg'=>'成功'));
}else{
return json_encode(array('code'=>0,'msg'=>'失败'));
}
}
public function
}
Call Stack
- in Index.php line 220
- at think\__include_file() in Loader.php line 85
- at Loader::autoload()
- at spl_autoload_call()
- at class_exists() in Loader.php line 478
- at Loader::controller() in App.php line 580
- at App::module() in App.php line 456
- at App::exec() in App.php line 139
- at App::run() in start.php line 19
- at require('/data/wwwroot/td.880...') in index.php line 23
Environment Variables
GET Data
Cookies
Server/Request Data
ThinkPHP Constants
if($res){
return json_encode(array('code'=>1,'msg'=>'成功'));
}else{
return json_encode(array('code'=>0,'msg'=>'失败'));
}
}
public function
}
Call Stack
- in Index.php line 220
- at think\__include_file() in Loader.php line 85
- at Loader::autoload()
- at spl_autoload_call()
- at class_exists() in Loader.php line 478
- at Loader::controller() in App.php line 580
- at App::module() in App.php line 456
- at App::exec() in App.php line 139
- at App::run() in start.php line 19
- at require('/data/wwwroot/td.880...') in index.php line 23
Environment Variables
GET Data
Cookies
Server/Request Data
ThinkPHP Constants
23Nov2024
if($res){
return json_encode(array('code'=>1,'msg'=>'成功'));
}else{
return json_encode(array('code'=>0,'msg'=>'失败'));
}
}
public function
}
Call Stack
- in Index.php line 220
- at think\__include_file() in Loader.php line 85
- at Loader::autoload()
- at spl_autoload_call()
- at class_exists() in Loader.php line 478
- at Loader::controller() in App.php line 580
- at App::module() in App.php line 456
- at App::exec() in App.php line 139
- at App::run() in start.php line 19
- at require('/data/wwwroot/td.880...') in index.php line 23
Environment Variables
GET Data
Cookies
Server/Request Data
ThinkPHP Constants
Hot Tools
php常用表单验证类
php常用表单验证类
PHP代码实现表单数据验证类库
PHP代码实现表单数据验证类库
validation数据验证库
validation数据验证库
功能齐全的php验证类
功能齐全的php验证类
validation-Laravel的验证库
validation-Laravel的验证库