variables

Wrap text - case insensitive with php

If I search for tOm ArNfElD and the $variable is "Tom Arnfeld", I get great results form LIKE in MySQL (which is case-insensitive). How could I wrap the matched text in the $variable with a <span></span> to highlight to what part of the search matched the query? I need to retain the original case of the $variable. ...

PHP: Functions have no idea variables even exist.

I've noticed an annoying peculiarity in PHP (running 5.2.11). If one page includes another page (and both contain their own variables and functions), both pages are aware of each others' variables. However, their functions seem to be aware of no variables at all (except those declared within the function). My question: Why does that h...

JScript.NET private variables

I'm wondering about JScript.NET private variables. Please take a look on the following code: import System; import System.Windows.Forms; import System.Drawing; var jsPDF = function(){ var state = 0; var beginPage = function(){ state = 2; out('beginPage'); } var out = function(text){ if(state == 2){ var st = 3; } M...

Setting document.body.className as a variable

This is my code to switch the class of my body tag when a user clicks a link. function switchBodyColor() { if (document.body.className == 'blue') document.body.className = 'red'; else if (document.body.className == 'red') document.body.className = 'green'; else if (document.body.className == 'green') ...

Is there a way to reference a variable from an external document with PHP?

Hi! I wanted to use PHP do do a little thing, but I needed to know how to get a variable from an external document (say external.php) and use it in a function in a PHP document (internal.php). I was thinking maybe something like this: Code for external.php $variable = "true"; Code for internal.php if ($GETFROM{'/external.php'}['var...

what kind of datatype should i use for this 600851475143 in c++?

i'm using c++, even if i declare long int, there is error like...... long int num = 600851475143; warning: integer constant is too large for ‘long’ type which datatype should be used in this case? ...

Ruby on Rails: Initializing instance variables with helpers in view

I'm running into some type of a scope issue that's preventing instance variables from being properly initialized by helpers called from the view. #sample_controller.rb class SampleController < ApplicationController def test end end #application_controller.rb helper_method :display def display if not defined? @display return ...

Is there anyway to access a listing of all PHP variables?

I created a singleton registry to contain instances of all my objects, and I try to unset variables when they are no longer in use. However, I can't seem to ever find all of the variables in use. There always seems to be a couple hundred KB that I can't explain floating around... I'm not sure it this is possible, but can you access an i...

Handling metacharacters in search strings

I have a user input that would be used in a search string that may contain a metacharacter For e.g. C# or C++ my grep command in a function was: grep -E "$1|$2" test.txt under direct replacement: grep -E "C\+\+|testWord" test.txt grep -E "C\#|testWord" test.txt the first caught the lines fine but not the second. Strangely, # was...

define variable in repeater?

Hi I like to handle and compare a lot of date times in my repeater even I have to work more than one time with the same. It's a bit ugly, to cast everywhere the Eval("MyDate") like ((DateTime)Eval("MyDate")) to substract 2 datetimes or to compare it, even if you have to do this more than in one operation. I thought of saving all the e...

How To Print ASCII Extended Characters Using a Const Char*?

I have a function to print characters on the screen that is like this: void print(int colour, int y, int x, const char *string) { volatile char *video=(volatile char*)0xB8000 + y*160 + x*2; while(*string != 0) { *video=*string; string++; video++; *video=colour; video++; } } And I want to prin...

Any way to reuse Bindings in WPF?

I'm getting to the point in a WPF application where all of the bindings on my controls are getting quite repetitive and also a little too verbose. Also if I want to change this binding I would have to change it in various places instead of just one. Is there any way to write the source part of the binding once such as in a resource and...

Detour to get a Global Pointer?

Hey guys, I need to get the protocol version of an application, and I don't know too much about the inner workings of detouring. I usually use a detour class written by a friend of mine (Not windows detour, as this works on win/linux) but im wondering if anyone can give me some insight on how to retrieve the value of a global pointer? I...

Passing a PHP variable

Hi there, I have the following php code below... if ($username == 'fredk') { $fname = 'Fred'; } else if ($username == 'arbonk') { $fname = 'Arbon'; } else if ($username == 'arsalana') { $fname = 'Arsalan'; } else if ($username == 'minhn') { $fname = 'Minh'; } else if ($username == 'nathanielg') { $fname = 'Nathaniel'; } $msg =...

In java, why I can declare a varaible named "a" but not "1" ?

Everything is fine when I declare String a; but it says Syntax error on token "1", invalid VariableDeclaratorId when I do this String 1; I guess it must be very trivial but I don't get it. ...

How to define /declare a class intance in a .hpp / .cpp file?

Hello, I'm pretty sure that this question is very noob but I'm not used to C++. I have a .hpp for class definition and a .cpp for class implementation. I have some private instances on the class, for example: class Test { Test(void); private: SomeClass anInstance; }; To create the instance and call the constructor do...

Passing SQL to an Oracle bind variable

Hi, I need to execute something like: select [very big SQL] where phone_number in(:SQL2) Is it possible to use bind variable for SQL2? I want to save the execution plan of the major SQL. Thanks. ...

Does a static variable takes only one memory location for all running threads?

Given that a static variable of a class takes only one memory location, is it shared by all threads of process? Or is one memory location for such a variable created for each of the running threads? Also, if all threads share the same memory location, how can we ensure mutual exclusion? ...

Conditionally appending to a variable inside a Makefile target

I have a GNU Makefile that looks a bit like this: LIST = item1 .PHONY: targetMain targetA targetB preA preB targetMain: # DO all the work in here echo $(LIST) targetA: preA targetMain targetB: preB targetMain preA: LIST += itemA preB: LIST += itemB The idea is that I either run make targetA or make targetB. Both of them do a ...

"function foo(bar) { }" versus "foo = function(bar) { }"

function foo(bar) { // ... } and foo = function(bar) { // ... }; What is the benefit of one versus the other? The main benefit I see in the latter is not running into errors with a function name already being defined. However, there may be other benefits or drawbacks that aren't obvious. What are they (if any)? ...