variables

Codeigniter: Set 'global variable'

If I want to set a variable that my whole controller can access, how do I do it? Right now, in every function I am setting $id = $this->session->userdata('id'); I'd like to be able to access $id from any function w/o defining it for each controller. :) If there's a better way, I'm all ears! I'm a noob! ...

How to wait for a variable to return before the next function starts

I have a simple function1 that does a http request to a google api and returns the $result. I then have another function2 that, if $result isset, should use $result to do some computing and then return $finalresult. . My problem is that the call to the google api takes a couple of seconds and by the time $result is returned by function1...

Changing the value of a var via reference in AS3

I'm pretty positive what I want to do isn't possible with ActionScript, but it would be nice to be wrong. I need to pass a variable reference to a function, and have the function change the value of the variable. So, simplified and not in completely correct syntax, something like this: function replaceValue(element:*, newValue:String)...

IDL - define array name within a loop

I may be going about this the wrong way, but I'm trying define and fill arrays within a loop. for i = 0,39 do begin xx = long(findgen(n+1l)*sx + line1x[i]) sz = size(xx) arrayname = 'line' + strtrim(i,2) arrayname = findgen(3,sz[1]) arrayname[0,*] = xx arrayname[1,*] = yy arrayname[2,*] = vertline endfor This obviously won't work, ...

Creating temporary variables to enhance readability.

I would like to know if there are any significant disadvantages to creating a temporary variable for a value that is accessed multiple times within a small scope. eg: filep->waypt[rp->leg[j]].ID or (*(filep->route + filep->nroutes - 1))->number These are examples from a recent project where I forced myself to avoid almost any simp...

how to randomize an integer variable, with odds on certain numbers appearing

To get a random whole number between 0 and 4 inclusive, I use the following code: var random = Math.floor(Math.random() * 5); However I want the number 4 to be chosen twice as often as the other numbers. How would I go about doing getting a random number between 0-4 inclusive, but with the number 4 appearing twice as many times as 0-3...

Php inheritance superclass variables

Hi! I try to load an entity with some details and there is a resellerId in the entity. Now I inherit a subclass from it, and try to access the resellerId but it's not there. How to pass the attributes to the subclasses? I really need it loaded. Thanks! edit: class Crm_Entity extends Crm_Abstract { protected $_mapper = 'Crm_Mapp...

append number to variable name and call it in a loop (php) (smarty)

Hi. I have a simple question. I need to append 1,2,3 etc to a variable name in smarty. The variables are $user1, $user2, $user3 etc. I use smarty to do a simple loop like this: {section name=user_info start=1 loop=$users} <tr> <td> User{$smarty.section.user_info.index} </td> // prints user1, user2, user3 etc ...

PHP - How to share / pass variables across different methods in a PHP Class

I am trying to set a value from a method of a class and trying to get it in another method. The example code is as below. I think the below kind of set/get works in a Java class. Googled out but still could not find a relevant solution. Searched: http://www.google.co.in/search?hl=en&amp;client=firefox-a&amp;rls=org.mozilla%3Aen-US%3Aof...

Calling PowerShell from batch, and retrieving the new value of a temporary environment variable set in the script?

Hey guys! I hope the title is concise, but just in case: I am calling a PowerShell script from a batch file. I want the PowerShell script to set the value of an environment variable, and for that new value to be available in the batch file when the PowerShell script finishes. I know that it is possible to set an environment variable u...

sed, environment variable and date problem

I want to add a timestamp to server events and store the result in a log. My first idea was : ( ./runServer.sh ) | sed "s/.*/`date +%s` & /" | xargs -0 >Server.log 2>&1 & But it seems sed never reevaluates the date, so all events get the same timestamp. Now I'm trying to get around that using environment variable but I can't find ...

PHP get variable from function

function first() { foreach($list as $item ) { ${'variable_' . $item->ID} = $item->title; // gives $varible_10 = 'some text'; (10 can be replaced with any number) } $ordinary_variable = 'something'; } How to get values of this function inside an another function? Like: function second() { foreach($list ...

Javascript local variable works like class variable in window

I find this behavior of the global window object a little weird. var x = 10; function SomeClass(){ var y = 15; console.log("Someclass:y - " + this.y); //prints undefined } console.log("window.x: " + window.x); //prints 10 var obj = new SomeClass(); console.log("obj.y: " + obj.y); //prints - undefined Both variables x and ...

iphone ipad class vars from info.plist

Hey Guys, So I have a lot of configuration settings in the plist, but do not like to invoke the infoDictionary all the time when accessing the objects. I was thinking to load all the configuration into a settings class and make that accessible throughout the application. So in the plist, say I have a key "font" and a string "Arial". ...

ASP equivalent of PHP print_r

Plain old ASP, not .NET I've got a really large and complicated class for making an upload progress bar and I'm trying to find out the uploaded file name. I think easiest way to accomplish that would be dumping the variable structure but, even if it isn't (and I appreciate if someone can point me), I've ended up wondering about it and t...

trying to put a php variable into the code for the "twitter for wordpress" plugin

Hi I am using the 'twitter for wordpress' plugin to display the last tweet in wordpress. it works fine but needs the username for the twitter account harcoded into the line of code: <?php twitter_messages('myaccount', 1, false, false, false, true, true, false); ?> What im trying to do is replace 'myaccount' with a variable ...

Problem with objects in php

Hi. I am trying to get used to writing object oriented, but often I get a little stuck. I have this queries that I want to use to create arrays. $user1 = mysql_fetch_object(mysql_query("SELECT * FROM tbl WHERE username='$oc->user1'")); $user2 = mysql_fetch_object(mysql_query("SELECT * FROM tbl WHERE username='$oc->user2'"...

Defining variables for use in both Makefiles and Shell scripts

I'd like to distribute a set of build variables (which someone should append to their LDFLAGS), in a form that can both be included in a Makefile and in a shell script. What I have now is a file buildflags.conf: LDFLAGS_EXTRA="-static -foo -bar" I want my users to be able to, when they're using makefiles: include buildflags.conf LDF...

PHP saving variables

There is a $variable, its value is a big Array(). It is created inside the function one() { ... } on the first.php page. first.php has form with method="post", after submition page reloads on second.php Is there any way to get value of $variable inside function two() { ... } on the second.php? Seems I can post value of $variable wit...

Public Static Variables c# Used correctly?

As mentioned in a previous post, I am currently learning C#, and for my first (well second if you include hello world and some messing about) real project, I'm going to create a basic EPOS system and then expand upon it.. My intention is to have all pricing, Cashier details, sales transactions, etc.. stored within a MySQL Database (I ca...