scope

is $_POST in php truly superglobal? [closed]

感情迁移 提交于 2019-12-25 00:21:52
问题 As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 7 years ago . Why am i asking this ? I'm trying hard to fathom php's superglobal concept ... array data/variables for $_POST are only available to

Java vs. JavaScript variable scope [closed]

蓝咒 提交于 2019-12-24 21:19:58
问题 It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 7 years ago . In the following Java snippet, the scope of i is limited to the inside of the for loop. That's why it causes an error. However, in the similar JS snippet, the i is apparently accessible outside of the loop. How

Scoping issue memoising bash function with associative array

孤街醉人 提交于 2019-12-24 21:08:46
问题 I have a bash script which uses jq to look up 'dependency' data in some JSON, and take the closure (find dependencies of dependencies of dependencies, etc.). This works fine, but can be very slow, since it may look up the same dependencies over and over, so I'd like to memoise it. I tried using a global associative array to associate arguments with results, but the array doesn't seem to be storing anything. I've extracted the relevant code into the following demo: #!/usr/bin/env bash #

Why does a global variable captured in a $.get() callback closure always hold the same value?

心已入冬 提交于 2019-12-24 18:36:05
问题 I'm having a bit of trouble capturing the value of a global variable in my $.get() callback: Relevant markup <div class="block" id="blog"></div> <div class="block" id="music"></div> <div class="block" id="video"></div> Relevant code $('div.block').each(function() { $this_id = $(this).attr('id'); alert($this_id); // outputs: blog, music, video $.get('test.php', {id: $this_id}, function(data) { alert($this_id); // outputs: blog, blog, blog (WHY?) $('div#' + $this_id).html(data); }); }); I'm

Accessing a variable outside of a for loop in Python if global doesn't work?

放肆的年华 提交于 2019-12-24 18:23:14
问题 I'm trying to find a similar record between two data sets in a dictionary with which to do further comparisons. I've confirmed with a print statement that it is finding a matching data set (so all of the code before the final if statement is working). However it is not setting the matchingSet2Record for some reason. This causes the final if statement to always run even though it is finding a match. Declaring the variable as being in the global variable scope does not work. What is causing

Use variable across multiple Cpp files

﹥>﹥吖頭↗ 提交于 2019-12-24 18:12:58
问题 Have searched enough answers but none of the solutions work for me. scenario : I am trying to include a .h file that has some functions declared (not defined) and some variables declared. If I include this header file in the source files (2 to be precise) that actually use the functions and variables, then the last one that compiles has a linker error that states undefined reference to `abc::myfun(char const*, char const*, char*)' All the functions and variables in the header files have been

Inject javascript function into parent window from iframe

六眼飞鱼酱① 提交于 2019-12-24 17:37:28
问题 I'm working on a project that has many iframes that are opened and closed in a parent window. I have an object that needs to be defined and shared between the iframes. The issue I'm running into is that when the iframe that created the object on top is closed the functions associated with it are lost. Is there a way I can define an object on top that will be accessible from my iframes even after the original iframe goes out of scope? 回答1: We came across this problem and this question and

R - How to find the environment where a function is called from inside the called function?

删除回忆录丶 提交于 2019-12-24 17:25:16
问题 I'm trying to create a function that references the scope from which it was called to create a unique ID: uniqueid <- function(name, envir = NULL) { if(identical(envir, globalenv())) { e = envir } else if (is.null(envir)) { e = parent.frame() } else if (is.environment(envir)) { e = envir } else { stop("given non-default argument \'envir\' is not an environment") } return(paste(sep = "", sub('<environment: (.*)>', '\\1', capture.output(e)), ".", name ) ) } What can I do to make this work the

Getting snapshot from webcam in Matlab

让人想犯罪 __ 提交于 2019-12-24 16:08:06
问题 I have created a simple GUI to preview webcam stream and to get snapshot from it. For this I have created on axes to show video, one push button(pushbutton1) to start preview, one push button(pushbutton2) to get snapshot. Following is the code for these two push buttons. function pushbutton1_Callback(hObject, eventdata, handles) % hObject handle to pushbutton1 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see

How to create variable outside of current scope in Tensorflow?

ε祈祈猫儿з 提交于 2019-12-24 16:04:27
问题 For example I have code like this: def test(): v = tf.get_variable('test') # => foo/test with tf.variable_scope('foo'): test() Now I want to make a variable outside of scope 'foo': def test(): with tf.variable_scope('bar'): v = tf.get_variable('test') # foo/bar/test But it is placed as 'foo/bar/test'. What should I do in test() body to place it as 'bar/test' without 'foo' root? 回答1: You can clear the current variable scope by providing an instance of an existing scope. So in order to pull