我正在使用PHP中的电子邮件验证正则表达式,我需要知道TLD可能存在多长时间并且仍然有效.我做了一些搜索,但找不到有关该主题的更多信息.那么TLD可能需要多长时间?
如何处理函数声明?
var abc = '';
if(1 === 0){
function a(){
abc = 7;
}
}else if('a' === 'a'){
function a(){
abc = 19;
}
}else if('foo' === 'bar'){
function a(){
abc = 'foo';
}
}
a();
document.write(abc); //writes "foo" even though 'foo' !== 'bar'
Run Code Online (Sandbox Code Playgroud)
此示例在Chrome和Firefox中生成不同的输出.foo
FF输出时输出Chrome 19
.
我想检测元素的焦点事件,但只有当用户按Tab键启动时才会检测到它.例如:
<input type="text" id="foo" />
<input type="text" id="detect" />
Run Code Online (Sandbox Code Playgroud)
如果用户专注于#foo
并按下Tab,我希望一旦#detect
聚焦(或焦点事件内的条件为真)就触发事件.相反,如果用户只是单击该#detect
字段来聚焦它,我不希望触发该事件(或者我希望焦点事件调用中的条件为假).
我不想使用keydown事件#foo
并检查Tab键是否被按下,因为我希望该方法独立于任何其他元素.
我查看了以下代码的控制台输出,但没有注意到两种聚焦方法之间的任何真正差异:
$('#detect').on('focus', function(e){
console.log(e);
});
Run Code Online (Sandbox Code Playgroud)
(小提琴)
这有可能以一种相对简单的方式完成吗?
我刚开始学习Python,现在我很丢失.我想在通过hosting24.com托管的服务器上运行我的脚本.他们的常见问题解答说他们支持Python,但我不知道在哪里放置我的脚本来运行它.
在我的根目录中有一个名为cgi-bin的文件夹,我猜这是我放置脚本的地方?有人可以向我解释这是如何工作的吗?
我们的专栏目前正在整理latin1_swedish_ci
,特别是unicode字符显然已被剥离.我们希望能够接受字符,例如U+272A ?
,U+2764 ?
(见这个维基百科文章)等我倾向于utf8_unicode_ci
,将这种整理处理这些和其他字符?我不关心速度,因为这个列不是索引.
MySQL版本:5.5.28-1
我正在使用IntelliJ IDEA 12使用CodeIgniter框架开发PHP Web应用程序.由于CI实例化对象和方法的方式,IDEA认为它们在被调用时不存在:
正如您所看到的,我尝试使用的每个CodeIgniter类/方法下都会遇到令人讨厌的橙色波浪形.
这是CI_Controller
该类的代码,可以深入了解它们如何创建对象:
class CI_Controller {
private static $instance;
/**
* Constructor
*/
public function __construct()
{
self::$instance =& $this;
// Assign all the class objects that were instantiated by the
// bootstrap file (CodeIgniter.php) to local class variables
// so that CI can run as one big super object.
foreach (is_loaded() as $var => $class)
{
$this->$var =& load_class($class);
}
$this->load =& load_class('Loader', 'core');
$this->load->initialize();
log_message('debug', "Controller Class Initialized");
}
public static function &get_instance() …
Run Code Online (Sandbox Code Playgroud) 我有一个更新个人资料页面.它有三种形式,它使用get请求来显示任何一种形式.就像update_profile.php?type=profile
让用户编辑他的个人资料一样,update_profile.php?type=settings
让用户编辑他的帐户设置.
类型:个人资料有文件输入,我希望用户能够在没有页面刷新的情况下上传.现在这不能使用ajax完成,所以我需要一个解决方法.我已经尝试过iframe方法,xhr2方法和html5 + ajax方法,有人在stackoverflow上发布了这个方法.
因此,如果有人愿意通过详细的步骤向我解释事情,我将不胜感激.这是我的HTML:
<script type='text/javascript'>
function nouser() {
$().toastmessage('showToast', {
text : 'The user does not exist',
sticky : true,
position : 'middle-center',
type : 'error',
closeText: '',
close : function () {
console.log("toast is closed ...");
}
});
}
</script>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<title>Update Profile</title>
<link rel="shortcut icon" type="image/png" href="includes/template/images/favicon.png" />
<link rel="stylesheet" type="text/css" href="includes/template/css2/style.css" />
<link rel="stylesheet" type="text/css" href="includes/jquery/toast/resources/css/jquery.toastmessage.css" />
<link rel="stylesheet" type="text/css" href="includes/jquery/notification/css/jquery_notification.css" />
<script type="text/javascript" src="includes/jquery/jquery_v_1.4.js"></script> …
Run Code Online (Sandbox Code Playgroud) 我正在尝试下载页面的HTML(http://www.google.com
在这种情况下),但我收到了错误.这是我的交互式提示会话:
Python 3.2.2 (default, Sep 4 2011, 09:51:08) [MSC v.1500 32 bit (Intel)] on win
32
Type "help", "copyright", "credits" or "license" for more information.
>>> import urllib
>>> import urllib.request
>>> html = urllib.request.urlopen("http://www.google.com")
Traceback (most recent call last):
File "\\****.****.org\myhome\python\lib\urllib\request.py", line 1136, in
do_open
h.request(req.get_method(), req.selector, req.data, headers)
File "\\****.****.org\myhome\python\lib\http\client.py", line 964, in req
uest
self._send_request(method, url, body, headers)
File "\\****.****.org\myhome\python\lib\http\client.py", line 1002, in _s
end_request
self.endheaders(body)
File "\\****.****.org\myhome\python\lib\http\client.py", line 960, in end
headers
self._send_output(message_body)
File …
Run Code Online (Sandbox Code Playgroud) PHP PDO语句是自动转义还是只准备好语句?
例如,假设$username
和$password
是用户输入.以下代码是安全的,还是容易受到注入?
$dbh = new PDO("mysql:host=localhost;dbname=mydb", $my_mysql_username, $my_mysql_password);
$sth = $dbh->query("SELECT * FROM users WHERE username='$username' AND password='$password'");
$result = $sth->fetch();
if(!$result){
$dbh->exec("INSERT INTO users (username, password) VALUES ('$username', '$password')");
}
Run Code Online (Sandbox Code Playgroud)
(以上代码纯粹是假设的,仅供参考.)
如果它们没有自动转义,PDO是否会mysql_
在这种情况下为这些功能提供额外的保护?
我正在尝试构建一个数组来创建一个菜单系统,其中每个索引都有2个对象,一个名称和一个字符串的字符串.
我试过这样的事情:
var menus = [];
menus.push({title:"Aztec", mySubArray:{"String1", "String2","String3"} });
Run Code Online (Sandbox Code Playgroud)
但这似乎不是正确的语法.有任何想法吗?
谢谢