/// <summary>
/// 从URL获取值(字符串)
/// </summary>
public static string GetValueFromUrl(string key)
{
string keyvalue = HttpContext.Current.Request.QueryString[key];
if (keyvalue != null)
{
keyvalue = KillBadString(keyvalue);
return keyvalue;
}
return "";
}
/// <summary>
/// 从URL获取值(整型)
/// </summary>
/// <param name="key"></param>
/// <returns></returns>
public static int GetIntValueFromUrl(string key)
{
string keyvalue = HttpContext.Current.Request.QueryString[key];
int result = 0;
if (int.TryParse(keyvalue, out result))
{
return result;
}
return result;
}
/// <summary>
/// 过滤SQL敏感字符
/// </summary>
/// <param name="str"></param>
/// <returns></returns>
public static string KillBadString(string str)
{
if (str == null || str.Length == 0)
{
return "";
}
str = System.Text.RegularExpressions.Regex.Replace(str, "'", "''");
return str;
}
本文介绍了Python操作MYSQL、执行SQL语句、获取结果集、遍历结果集、取得某个字段、获取表字段名、将图片插入数据库、执行事务等各种代码实例和详细介绍,代码居多,是一桌丰盛唯美的代码大餐。如果想查看在线版请访问:https://www.jb51.net/article/34102.htm
0
以上就是httpHelper 从URL获取值的实例代码的详细内容,更多请关注php中文网其它相关文章!
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号