How must we document (with phpDocumentor) constants defined with define() in PHP?
I found nothing in the docs, but found the following example (which I don't see it's use) in the sample2.php:
/**#@+
* Constants
*/
/**
* first constant
*/
define('testing', 6);
/**
* second constant
*/
define('anotherconstant', strlen('hello'));
...
Selecting constants without referring to a table is perfectly legal in an SQL statement:
SELECT 1, 2, 3
The result set that the latter returns is a single row containing the values. I was wondering if there is a way to select multiple rows at once using a constant expression, something kind of:
SELECT ((1, 2, 3), (4, 5, 6), (7, 8, 9))...
Is there a way in PHP to include a constant in a string without concatenating?
...
I'm using constants for output messages in different languages.
For example, if a user chooses "English", a file with this constant would be required:
define('welcomeMessage','Welcome!');
If she chooses "Spanish":
define('welcomeMessage','Bien Venidos!');
etc etc...
The problem occurs when a user iterates through languages. I can...
In .NET I can get the VK value of a pressed key in the "KeyDown" event.
Wath I need is the DIK value of the pressed key. How do I do this?
I tried to use the MapVirtualKey API. But it doesn't work with all keys. (works with the ones in the main keyboard).
Is there an easy way to do this?
...
I wish to assign to a variable (a "constant"), a value that will allow that variable to only ever return True in is and == comparisons against itself.
I want to avoid assigning an arbitary value such as an int or some other type on the off chance that the value I choose clashes with some other.
I'm considering generating an instance of...
class My_class
{
const STATUS_ERROR = 0;
const STATUS_OK = 1;
const DB_TABLE = TABLE_PREFIX . 'class_table';
}
The two status consts work fine and can be accessed within class methods as self::STATUS_ERROR and self::STATUS_OK just fine.
The issue is one of how to stop the following error being thrown when I try to define th...
I have read (and generally agree) that to increase code legibility, you should use constants instead of magic numbers as method parameters. For example, using PHP:
// no constants ////////////////////
function updateRecord($id) {
if ($id == -1) {
// update all records
} else {
// update record with "id = $id"
...
So I'm chugging along in learning C++ and I'm starting to use Eclipse. As I create my .h files, I get this strange #define constant at the top:
#ifndef CLASSNAME_H_
#define CLASSNAME_H_
#endif /* CLASSNAME_H_ */
So, what gives? Am I supposed to use CLASSNAME_H_ for something?
(I should note that "classname" is just a filler. So, fo...
I've got a static property I would like to access by importing it's class without instantiating an object of that class. Is this possible?
Essentially I'm writing a bunch of styleSheet Objects over and over. I figure If I have a class called CSS and like this:
package com
{
import flash.text.*;
public class CSS
{
pu...
Arrays are implemented as objects in java right? If so, where could I look at the source code for the array class. I am wondering if the length variable in arrays is defined as a constant and if so why it isn't in all capital letters LENGTH to make the code more understandable.
EDIT: http://java.sun.com/docs/books/jls/second_edition/htm...
I have a constant that is only used in views, but it's used in different ways in different places. It's an array of option names, and is used for select boxes, but I also use this in other views to see if strings are found in this array, and respond accordingly.
What's the best way to handle this to keep DRY?
I initially created a con...
Hi. I'm new to rails and getting the following error:
NameError in FriendshipsController#create
uninitialized constant FriendshipsController
this also shows up:
{"authenticity_token"=>"eQvv3flATE+P1TEErOWP/6fM8dEOIBxltobCxtM/F18=",
"friend_id"=>"32"}
When I click on the "Add Friend" Link on my users show page. I am following th...
I have a procedure that accepts 2 string parameters, one of them has a default value. Inside the procedure, I want to concatenate one and the other and some literals to form one larger string. Somehow, I'm getting an AV... any ideas?
code is something like this
{$WRITEABLECONST ON}
constructor MyClass.Create(s1: string; s2: string = Gl...
Id expect this to work (below)
If iTestVar is 1, I'd expect DoStuff() to be fired. However it always falls into the else.
I have researched const in the past and found they can only be defined outside of classes. The select statement is inside the class.
'This is defined outside of the class (vbscript won't allow const inside c...
Hey guys,
I'm trying to get the value of a constant of an extending class, but in a method of the abstract class. Like this:
abstract class Foo {
public function method() {
echo self::constant;
}
}
class Bar extends Foo {
const constant = "I am a constant";
}
$bar = new Bar();
...
I have a function like (please don't care about returning temporary by reference. This is just an example to explain the problem),
const foo<const int>& get_const()
{
foo<int> f;
return f;
}
This obviously won't compile. I am looking for a way to ensure callers won't change the T of foo. How can I ensure that?
I have seen the...
This question about why constants in Java are uppercase by convention made me try to think of counter examples.
I can think of at least one (Double.NaN). Are there others?
...
I've just come across some code that's confusing me slightly; there are really 2 variations that I'd like to clarify.
Example 1:
public String getFilepath(){
final File file = new File(this.folder, this.filename);
return file.getAbsolutePath();
}
What would be the purpose of declaring file "final"? Since Java prim...
Please consider the following code.
struct foo
{
};
template<typename T>
class test
{
public:
test() {}
const T& value() const
{
return f;
}
private:
T f;
};
int main()
{
const test<foo*> t;
foo* f = t.value();
return 0;
}
t is a const variable and value() is a constant member-function...