variables

PHP: Variable in a function name

I want to trigger a function based on a variable. function sound_dog() { return 'woof'; } function sound_cow() { return 'moo'; } $animal = 'cow'; print sound_{$animal}(); * The * line is the line that's not correct. I've done this before, but I can't find it. I'm aware of the potential security problems, etc. Anyone? Many thanks. ...

Why use public variables?

Variables, methods and classes can receive various security levels. From my C# experience, there is: public internal protected protected internal private Now, I understand the use of making methods and classes private, or internal or protected, but what about variables? Even if I make a variable private, I can use a Property to call it...

setting strings in gdb

c++: int main() { string a = "a"; ... ... } when i debug in gdb: (gdb) set var a = "ok" Invalid cast I run the program and pause at a break point after string a has been initialized. I'm trying to set its value, but it complains about invalid cast. What's the proper syntax for this? ...

Dynamic variable based on database record/recall - Help?

OK, I'll keep this as short as I can.. I am trying to create a truly scalable environment for my users and so allow them to.. 1. define a new option (dshop_options_name) 2. define option values (dshop_options_values) separate tables in the database This is to allow distinct values to be assigned and also in any combination. OK, the scr...

populate a $_REQUEST variable value from database record - how?

I am trying to get the values posted from a form select. The select name is dynamic, meaning that the name value is defined by a database record. In the form processing script, I want to call back that value via a $_REQUEST. I cannot know in advance what the value of the $_request will be (eg, $var=$_REQUEST['foo']; ) but I do know tha...

PHP Variable Scope

Is there a way to declare a variable so it is available in all functions. Basically I want to call: Global $varName; automatically for every function. And no, I can't use a constant. I don't think its possible but wanted to ask anyway. Thanks! :D ...

PHP object has semicolon (or other strange character) in variable name

Hi, I've got an object, which contains semicolons in the property names, when I var_dump, I get: object(Sales) { [thisisa:propertyname] => 'some value' } So, how do I access the property? $object->thisisa:propertyname throws an error. I read somewhere a while ago you can wrap thisisa:propertyname in some characters (I've tried ...

Log4J – Runtime variable substitution

Log4J appears to have an annoying restriction – at runtime, variable substitution does not appear to work. In this example File: Log4j.properties file_pattern=%d{ISO8601} %-5p %m%n log4j.rootLogger=DEBUG, FileAppender log4j.appender.FileAppender=org.apache.log4j.FileAppender log4j.appender.FileAppender.layout=org.apache...

Assigning variables based on sting data

Hi Gang, I have a inefficiently constructed form that is obviously sending one type of data per SELECT element. For simplicity's sake, here's an example. The form posts data from 2 SELECT elements, but it actually needs to contain 3 pieces of data. To the user, the SELECTs do contain 3 pieces of data; one SELECT denotes quantity and th...

Is it possible to create eventlisteners for string, int, bool at all?

Is it possible at all to create eventlisteners (i.e. when the value changes) for a variable of type string, int, bool, etc.? I haven't seen this in any programming language so far, except for some Collections (like ArrayCollection in Flex), which use events to detect changes in the collection. If not possible at all, why not? What's t...

AppDelegate Being accessed from different classes, from RootController.m

Hi All, My problem is in getting the information from a controller(which happens to be my rootViewController) to another view. In trying to get access to it through the app delegate, I was not able to get it working. I have found how to do this, but this inturn created another problem of getting the view inside a modal view controller t...

PHP losing data for two variables

I have two scripts that I'm working on. The first receives $agentID via GET (as well as some other data via other GET variables), then looks up $firstName and $lastName in a database by $agentID. Once done, it displays $firstName, $lastName and $agentID on the screen, as text in a form (not in a form input). After the form is submitte...

Declaring a variable in an if-else block in C++

I'm trying to declare a variable in an if-else block as follows: int main(int argc, char *argv[]) { if (argv[3] == string("simple")) { Player & player = *get_Simple(); } else if (argv[3] == string("counting")) { Player & player = *get_Counting(); } else if (argv[3] == string("competitor")) { Player &...

Java Instance Variables vs Local Variables

Hi, I'm in my first programming class in high school. We're doing our end of the first semester project. This project only involves one class, but many methods. My question is best practice with instance variables and local variables. It seems that it would be much easier for me to code using almost only instance variables. But I'm not ...

Javascript Objects: Dynamic variable names?

This is probably a no-brainer, but how can I make this happen: var name = otherObject.name; //"string" var o = { name : otherObject }; alert(o["string"].name); Thanks in advance! ...

Why is this Variable Disappearing?

This should probably have a simple answer I just can't figure out. Anyway, I have a php document and inside of it I define <?php $pathprefix = '../'; ?> Later in the document I use an <?php require([somefile.php]); ?> and inside of somefile.php, I have a line that says <?php echo($pathprefix); ?> but the '../' I assigned to $pathprefix...

Setting Padding - why it says padding.all is not variable?

Hi, I do not understand why there is Control.padding.all which is int and according to hint there is set as well as get but I cannot set it (Control.Padding.All=5)? I would be grateful for explanation. Thanks! ...

How to use variable in target database name for insert statement?

I want to declare a server name and use this name in an insert statement. So far all i got is an error message. declare @machine nvarchar(6); declare @bar nvarchar(3); set @machine = 'Name00'; set @bar = 'foo' insert into @machine.dbname.dbo.table (column1, column2) select (column1, column2) from table where column1 = @bar This gives...

What's the difference between ‘var $x’ and ‘var x’ in jQuery?

Possible Duplicate: Why would a javascript variable start with a dollar sign? What's the difference between ‘var $x’ and ‘var x’ in jQuery? ...

If you can't change a variable's value in Haskell, how do you create data structures?

As per the title. I have the following code which creates a binary search tree, but if I want it created and changed dynamically with user input, how would I do that if I can't change the value of a variable in haskell?!? find :: (Ord a) => Node a -> a -> Bool find (Node val left right) s | s == val = True | s < val = find le...