我是php新手,我想在我的代码中使用php5的__autoload功能.我在index.php中编写了下面的代码,但我不明白我应该如何以及何时调用__autoload函数.
function __autoload($class) {
if (file_exists($class . '.php')) {
include($class . '.php');
} else {
throw new Exception('Unable to load class named $class');
}
}
Run Code Online (Sandbox Code Playgroud)
我也见过这个帖子,但我的应用程序中没有这样的自动加载器类.每个应用程序是否需要单独的类才能使用自动加载?如果没有,我可以像上面这样的单一功能完成它的任务吗?任何人都可以解释如何在我的PHP代码中调用上面的__autoload函数?
是否存在某个城市/地点的邮政编码为“XXXX”并且属于 2 个或更多时区?
我不确定这个问题是否有效。但由于互联网上有关位置和时区的大量信息,我有点困惑。
(我的要求实际上是将用户的国家、城市、邮政编码和时区信息存储在数据库中)
database timezone geolocation postal-code google-maps-timezone
有没有一种使用html5自动表单验证来查找表单中哪些子元素无效的方法?
我知道我们可以通过调用checkValidity()方法逐个元素地检查。我正在寻找的是,如果有更短的方法。
例如,
var contactForm = document.getElementById('contact-form');
if (contactForm.checkValidity() == false) {
// something like contactForm.getInvalidChildren() and apply
// different style and error message based on the child type
}
Run Code Online (Sandbox Code Playgroud) autoload ×1
autoloader ×1
database ×1
geolocation ×1
html5 ×1
javascript ×1
php ×1
postal-code ×1
timezone ×1
validation ×1