constants

How to setup get_head(), get_foot(), and other files like wordpress uses.

I am trying to migrate my site to PHP and use a WP theme on my site with out modifying the theme too much. So my problem is that I want to create a functions.php file like in Wordpress that contains some code that can be called to load the header and footer of my sites theme from each page. Also I want to keep some constants in another f...

Different ways to define constants in C/C++

How many different ways are there to define constants in C or C++? I am already aware of using the const keyword and the #define directive. I heard somewhere that there are two more ways to define constants, but I've never seen any others. Are there any others? ...

defining global constants in java - avoiding magic numbers - best practice?

to avoid magic numbers, i always use constants in my code. back in the old days we used to define constant sets in a methodless interface which has now become an antipattern. wondering what are the best practices? im talking about global constants. Is an enum the best choice for storing constants in java? thanks ...

PHP Class variables with Constants

I am getting a parse error on the lines with the constant (DEPLOYMENT). Why is this now allowed, or am I missing something. Parse error: parse error, expecting `')'' in class UploadComponent extends Object { private $config = array( 'accessKey' => 'XXXX', 'secretKey' => 'XXXX', 'images' => array( ...

get all class constants

Is there a way to do get all the constants in a php class. Tried get_class_vars( get_called_class() ) class Status { const PUBLISHED = "published"; const DRAFT = "draft"; public static function get_types() { return array(self::PUBLISHED, self::DRAFT); } } Thanks ...

PHP output of __FILE__ inside included file.

Ok, here is a real short query. I am calling __FILE__ from inside a function. Now, this function itself is in a required file. Now, when I call this function from inside the Parent file, will the __FILE__ output the parent file or the file which was included? Oh, and I am looking for a source where I can confirm, if possible, because m...

Why is `exists` modifying my constant?

The exists function can unexpectedly autovivify entries in hashes. What surprises me is that this behavior carries over to constants as well: use strict; use warnings; use Data::Dump 'dump'; use constant data => { 'foo' => { 'bar' => 'baz', }, ...

Visual Studio: How do I create my own defined constants based on the "Configuration Manager"?

Basically, when I select the "Debug" configuration, the DEBUG constant is active. When I select the "Release" configuration, the DEBUG constant is inactive. How can I create my own configurations so that they include my own defined constants. Basically, I want it so that if I select the configuration "FOOBAR" that there is a constant FO...

Storing integer values as constants in Enum manner in java

Hi, I'm currently creating integer constants in the following manner. public class Constants { public static int SIGN_CREATE=0; public static int SIGN_CREATE=1; public static int HOME_SCREEN=2; public static int REGISTER_SCREEN=3; } When i try to do this in enum manner public enum PAGE{SIGN_CREATE,SIGN_CREATE,HOME_SCREEN,REGISTER_SC...

Dynamic constant name in PHP

Hello all I am trying to create a constant name dynamically and then get at the value. define( CONSTANT_1 , "Some value" ) ; // try to use it dynamically ... $constant_number = 1 ; $constant_name = ("CONSTANT_" . $constant_number) ; // try to assign the constant value to a variable... $constant_value = $constant_name; But I find th...

Defining constants in python class, is self really needed?

I want to define a set of constants in a class like: class Foo(object): (NONEXISTING,VAGUE,CONFIRMED) = (0,1,2) def __init__(self): self.status = VAGUE However, I get NameError: global name 'VAGUE' is not defined Is there a way of defining these constants to be visiable inside the class without resorting to global or ...

Setting Clojure "constants" at runtime

I have a Clojure program that I build as a JAR file using Maven. Embedded in the JAR Manifest is a build-version number, including the build timestamp. I can easily read this at runtime from the JAR Manifest using the following code: (defn set-version "Set the version variable to the build number." [] (def version (-> (str "j...

Using constant objects in objective-c

I have a piece of code similar to this: //Foo.h OBJC_EXPORT MyObject *const myObj; // Foo.m MyObject *const myObj; @implementation Foo +(void) initialize { if (self = [Graph class]) { myObj = [Config get:@"Foo"]; // <--- ERROR! assignment of read-only variable 'Foo' // .... } } // .... @end This ...

Java: Can interfaces contain constant variables defined in them?

Hi, I am new to java, hence again another probably silly doubt. I just want to know whether I can create public static final variables in an interface file. I know interfaces are abstract classes which contain methods that must be implemented by any class which implements the interfcae. But my question is whether I can keep some common...

How to define non string constants in objective-C?

Hi guys, I can define global strings like this: // .h extern NSString * const myString; // .m NSString * const myString = @"String"; Now I need to define UIcolor similarly, How can I do it? I'm trying: // .h extern UIColor * const myColor; // .m UIColor * const myColor = [UIColor colorWithRed:1.0 green:0.0 blue:0.0 alpha:1.0]; ...

Setting OPT_SERVER_FAILURE_LIMIT on PHP Memcached library

I wanted to know how OPT_SERVER_FAILURE_LIMIT constant (which I think is equivalent of MEMCACHED_BEHAVIOR_SERVER_FAILURE_LIMIT on libmemcached) works, so created a small code snippet like this: #!/path/to/php533/bin/php <?php function debugging_set($memcached, $key, $value) { $code = '$memcached->set($key, $value)'; var_dump(eval('r...

what makes const at the lower levels of the machine?

When making something const in C++ what makes it that you cannot for example implicitly pass it a non-const at the lower levels of the machine? How is it determined by the machine that this is const? (besides the fact that const means what it means...) Is it perhaps stored in the .rdata section of memory or is there a bit that gets se...

Defining Constants in Django

I want to have some constants in a Django Projects. For example, let's say a constant called MIN_TIME_TEST. I would like to be able to access this constant in two places: from within my Python code, and from within any Templates. What's the best way to go about doing this? EDIT: To clarify, I know about Template Context Processors and...

How to name a constant in Objective-C?

What's the naming convention for constants in Objective-C (or most widely used way to name them)? Is there a different criteria for extern constants? Some styles I have seen: NSString* const kPreferenceFirstRun = @"FirstRun"; // Replace "XY" by a prefix representing your company, project or module NSString* const XYPreferenceFirstRu...

Java - Enum with array field

Hey, I want to store a list names and individual nicknames for each name as an Enum in Java. The number of nicknames will not vary. The purpose is to be able to get a full name from a nickname. Currently I have implemented this like so: public enum Names { ELIZABETH(new String[] {"Liz","Bet"}), ... ; private Strin...