Recent Posts

Showing posts with label variable. Show all posts
Showing posts with label variable. Show all posts

Angular JS: How to pass variables between controllers

One way to share variables across multiple controllers is to create a service and inject it in any controller where you want to use it. Simple service example: angular.module('myApp', []) .service('sharedProperties', function () { var property = 'First'; return { getProperty: function () { return property; }, setProperty: function(value) { ...

How to solve Undefined variable: _SESSION PHP

If you have this error then you must to call to session_start in the begining (at the top) of each php file where you want to use sessi...

How to access PHP variables in JavaScript or jQuery

To have access to PHP variables in JavaScript or jQuerys sometimes you have to write something like this: <?php echo $variable1 ?> <?php echo $variable2 ?> <?php echo $variable3 ?> ... <?php echo $variablen ?> This example shows the most simple way of passing PHP variables to JavaScript. You can also use json_encode for more complex things like arrays: <?php $simple = 'simple string'; $complex...

Python: How to pass a variable by reference

The Python documentation seems unclear about whether parameters are passed by reference or value, and the following code produces the unchanged value 'Original': class PassByReference: def __init__(self): self.variable = 'Original' self.Change(self.variable) print self.variable def Change(self, var): var = 'Changed' Arguments are passed by assignment. The rationale behind this is two fold: the...

JavaScript: variable scope

Javascript programmers are practically ranked by how well they understand scope. It can at times be quite counter-intuitive. A globally-scoped variable var a = 1; // global scope function one() { alert(a); } Local scope var a = 1; function two(a) { alert(a); } // local scope again function three() { var a = 3; alert(a); } Intermediate: No such thing as block scope in JavaScript var a = 1; function four() { if...