每天学一点7
2015-07-13 01:56
381 查看
1.注意:任何地方省略var关键字,定义的变量都是“全局变量”,因此,一般情况下,不要省略var关键字。
2.JavaScript 注释单行的注释以 //开始;多行注释以 /* 开头,以 */ 结尾
3.php中 isset()函数的作用是判断一个变量是否定义过。
4.内置函数str_replace可以实现字符串的替换。.
例子 $arr = “苹果很好吃”;
$arr = str_replace(‘苹果’,‘香蕉’,$arr);
echo$arr; 结果是 香蕉很好吃
5.当我们创建了自定义函数,并且了解了可变函数的用法,为了确保程序调用的函数是存在的,经常会先使用function_exists判断一下函数是否存在。同样的method_exists可以用来检测类的方法是否存在。
类是否定义可以使用class_exists。
6.js和php中try catch用法实例
<html>
<script>
function checkNum(number){
if(number){
throw new Exception(" 抛出错误");
}
returntrue;
}
try{
checkNum(2);
}catch( e){
alert("抛出错误");
}
</script>
<?php
header("Content-type: text/html;charset=utf-8");
function checkNum($number)
{
if($number>1){
throw new Exception("Value must be 1 or below");
}
return true;
}
try{
checkNum(2);
}catch(Exception $e){
echo$e->getMessage();
}
?>
</html>
7.如果有一个文件夹,专门用于定义类,则命名规范应当这样:类名.class.php
8.<ahref ="javascript:vido(0);"></a>;链接为空。
9.一般修改或许量的样式为 xx.style.display="none";
或者在style里面写个class样式如 .xx{display:none;}
xx.className= “xx”;
2.JavaScript 注释单行的注释以 //开始;多行注释以 /* 开头,以 */ 结尾
3.php中 isset()函数的作用是判断一个变量是否定义过。
4.内置函数str_replace可以实现字符串的替换。.
例子 $arr = “苹果很好吃”;
$arr = str_replace(‘苹果’,‘香蕉’,$arr);
echo$arr; 结果是 香蕉很好吃
5.当我们创建了自定义函数,并且了解了可变函数的用法,为了确保程序调用的函数是存在的,经常会先使用function_exists判断一下函数是否存在。同样的method_exists可以用来检测类的方法是否存在。
function func() {
}
if (function_exists('func')){
echo 'exists';
}
类是否定义可以使用class_exists。
class MyClass{
}
// 使用前检查类是否存在
if (class_exists('MyClass')) {
$myclass = new MyClass();
}
6.js和php中try catch用法实例
<html>
<script>
function checkNum(number){
if(number){
throw new Exception(" 抛出错误");
}
returntrue;
}
try{
checkNum(2);
}catch( e){
alert("抛出错误");
}
</script>
<?php
header("Content-type: text/html;charset=utf-8");
function checkNum($number)
{
if($number>1){
throw new Exception("Value must be 1 or below");
}
return true;
}
try{
checkNum(2);
}catch(Exception $e){
echo$e->getMessage();
}
?>
</html>
7.如果有一个文件夹,专门用于定义类,则命名规范应当这样:类名.class.php
8.<ahref ="javascript:vido(0);"></a>;链接为空。
9.一般修改或许量的样式为 xx.style.display="none";
或者在style里面写个class样式如 .xx{display:none;}
xx.className= “xx”;
相关文章推荐
- vimTAB宽度等设置
- vimTAB宽度等设置
- IOS开发小技巧——强大的企业级调试日志——IOS第三方库CocoaLumberjack/CocoaLumberjack(1)
- 邮箱 万维网通讯 smtp
- 3.Android Studio 之命令行开发安卓
- moodle在xampp环境下的安装以及使用
- 架构类
- codeforces 557d
- 架构类
- codeforces 540B-贪心
- cnblogs开源合集
- 计算机思维
- 画三角形
- Linux 上的数据可视化工具
- LINUX 暂停、继续进程
- Linux 上的数据可视化工具
- LINUX 暂停、继续进程
- sphinx实时索引和高亮显示
- 77个常用Linux命令和工具
- 必学100个常用linux命令大全