我有(或没有)$_GET['myvar']
来自我的查询字符串的变量,我想检查这个变量是否存在,以及该值是否与if语句中的内容相对应:
我正在做和想的不是最好的方法:
if(isset($_GET['myvar']) && $_GET['myvar'] == 'something')
: 做一点事
我的问题是,在没有声明变量两次的情况下,有没有办法做到这一点?
这是一个简单的案例,但想象一下,必须比较许多$myvar
变量.
我知道我可以申请模板/ templateURL,但目前内容将从我的应用程序的其他地方加载.
JSbin:http://jsbin.com/imuseb/1/
HTML
<html ng-app="app">
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.0.5/angular.min.js"></script>
</head>
<body>
<div alert>here</div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
JS代码:
var app = angular.module('app', []);
app.directive('alert', function (){
return {
link: function (scope, element, attrs) {
element.on("click", function (){
alert("here");
});
}
};
});
$(function (){
$("body").append("<div alert>here too</div>");
});
Run Code Online (Sandbox Code Playgroud) 它看起来像一个非常简单的问题,但我找不到任何地方,所以:
如何在Jquery中返回调用元素?
$("div#myid").foo(); //I want to return exactly "div#myid"
Run Code Online (Sandbox Code Playgroud)
谢谢
您好,我现在正在中级C课,这个想法刚出现在我脑海中:
int multi[3][4]; // const multidimensional array
int* ptr = *multi; // ptr is a pointer variable that hold the address of multi const array
Run Code Online (Sandbox Code Playgroud)
那么,访问多维数组位置的更快/更小/优化是什么?
这个:
multi[3][1]; // index the value position
Run Code Online (Sandbox Code Playgroud)
要么
*(*(multi+2)+1); // pointer to the position on the array
Run Code Online (Sandbox Code Playgroud)
或(更新)
ptr += 9; // pointer arithmetic using auxiliary pointer
Run Code Online (Sandbox Code Playgroud)
由于"multi"是一个const数组,编译器应该"知道"元素位置的本地化,如果使用指向该数组的变量指针可能需要更多的处理时间,另一方面在搜索时可能更快我想要显示的项目.什么是更快/更小/优化的方法?
先感谢您.