syntax

Passing Objects into PHP constructor error

Hello, Is it possible to pass an object into the constructor of a PHP class, and set that object as a global variable that can be used by the rest of the functions in the class? For example: class test { function __construct($arg1, $arg2, $arg3) { global $DB, $ode, $sel; $DB = arg1; $ode = arg2; $sel = $ar...

PHP: using the eval function with HTML and PHP code

Hey guys, I currently have the following code coming from a database table: <h1 class="widgetHeader">My Friends</h1> <div class="widgetRepeater"> <p class="widgetHeader">Random Selection</p> <?php $friends = $user->getFriends(); ?> <p class="widgetContent"> <?php for ($i=0; $i<count($friends);$i++) {...

Python NameError

list1 = [a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z] for item in list1: print item Not sure why the above code is throwing this error: NameError: "name 'a' is not defined" ...

What kind of syntax is this in PHP?

if(true): echo 'good'; endif; I've only see it in PHP today! I've always been using: if(true) { echo 'good'; } ...

C++ - Variable "not" declared

Hello everyone, this is my first time on stack overflow so please be nice to me =). Right now, I have a problem with my code, while developing, I have encountered this a million times, and managed to solve it. But right now, I'm writing some serious code, and was wondering. Why does its happens? What's the correct way to fix it up T...

Rails syntax for comments in templates: is this bug understood?

Using rails 2.3.2 I have a partial _foo.rhtml that begins with a comment as follows: <% # here is a comment %> <li><%= foo %></li> When I render the partial from a view in the traditional way, e.g. <% some_numbers = [1, 2, 3, 4, 5] %> <ul> <%= render :partial => "foo", :collection => some_numbers %> </ul> I found that the <li> and ...

What is the decimal separator symbol in JavaScript?

A thought struck me as I was writing a piece of JavaScript code that processed some floating point values. What is the decimal point symbol in JavaScript? Is it always .? Or is it culture-specific? And what about .toFixed() and .parseFloat()? If I'm processing a user input, it's likely to include the local culture-specific decimal separ...

What is this "iif" in php means?

Has anyone see this "iif" in php before? What is that actually? I try to search the documentation for it in php.net but I cant found any. Anyone can give a simple example of how to use this "iif"? ...

Closest language to Python's syntax that is more low level language!

Hi! I guess topic says it all! But, I really wan't a syntax similar to Python's! And low-level... like C++ for example. I guess Java and C# is OK too, but I really have a huge problem with the { }, and always ; <-- and each line. I hate it so much... ...

Ruby : `&:symbol` syntax

Possible Duplicate: Ruby/Ruby on Rails ampersand colon shortcut Seen in Railscast #167 : def tag_names @tag_names || tags.map(&:name).join(' ') end What is this &:name syntax, what does it do ? I understand what a symbol is, but what other kinds of objects this & can be prepended to ? Duplicate question : http://stac...

What do the plus and minus signs mean in Objective C next to a method?

I am very new in objective c and in xcode. I would like to know that what are the + and - signs next to a method definition mean. - (void)loadPluginsAtPath:(NSString*)pluginPath errors:(NSArray **)errors; ...

Nested JSON objects - do I have to use arrays for everything?

Is there any way to have nested objects in JSON so I don't have to make arrays out of everything? For my object to be parsed without error I seem to need a structure like this: {"data":[{"stuff":[ {"onetype":[ {"id":1,"name":"John Doe"}, {"id":2,"name":"Don Joeh"} ]}, {"othertype":[ {"id":2,"company":...

A really simple Java question

I'm trying to call angles from from the angle method down below in the Rotate90 method but I'm not sure of the syntax. What is the correct syntax? import java.lang.Math; public class CartesianPoint implements Point { private double xCoord; private double yCoord; public CartesianPoint (double xCoordinate,double yCoordinate) ...

Coregions in UML

What are coregions in UML sequence diagrams? ...

PHP difference between \r\n and \n

Simple question... I have seen people tell me to use "\r\n" in various places and others tell me to use "\n" in the same place. I'm sure one is right and one is wrong. Example - when designing mail() headers: Tutorial #1: //define the headers we want passed. Note that they are separated with \r\n $headers = "From: [email protected]...

Expected';' before numeric constant

hi plz tell me what to do in this type of error??? i have: NSString *a = @" b ="1.0" " ...

How can I nest this if/else as per Ruby?

I want to do this in ruby: something() if conditional else something_else() This doesn't compile, nor anything similar from what I tried. Is it possible to have statements in this format or do I have to do this as: if conditional something() else something_else() end ...

What's the term for calling a function this way?

unset $arr[$key]; Shouldn't it be : unset($query[$key]); ...

Ruby Print Inject Do Syntax

Why is it that the following code runs fine p (1..1000).inject(0) { |sum, i| sum + i } But, the following code gives an error p (1..1000).inject(0) do |sum, i| sum + i end warning: do not use Fixnums as Symbols in `inject': 0 is not a symbol (ArgumentError) Should they not be equivalent? ...

Whats the difference between float* varname and float *varname in classic c

What's the difference between float* varname and float *varname in classic C? ...