class

Do I need to grab a PHP class object in every method in a class?

I am working on some PHP classes, I have a session class used to set and get values to session variables, I will need to have access to this session class object in every other class so I made a singleton method in the session class and then in other class's methods I can call the session object like this.... $session = Session::getInst...

PHP error Can't use method return > value in write context

I am getting this error in a PHP class... Fatal error: Can't use method return value in write context in C:\webserver\htdocs\friendproject2\includes\classes\User.class.php on line 35 Here is the troubled part. if(isset($this->session->get('user_id')) && $this->session->get('user_id') != ''){ //run code } This code is...

How Can I Add a "Selected" Class Based on URL with jQuery?

I have a sidebar list of links in my wikispace theme that currently uses jQuery to apply a class to each of the sidebar links based on the URL after the .com/. You can see this being applied in the code below... <div class="WikiCustomNav WikiElement wiki"><a href="/" class="">Home</a> <a href="/Calendar" class="calendar">Calendar</a> <...

Can I have a class method include a header file for me in PHP?

Please review the example code below, I have a class file that is loaded into a config file. The config file is then loaded into any page I build. Is it possible to include a header file the way I have in the show_header() method? It doesn't seem to work so how can I achieve this result? // Core.class.php class Core { public fun...

Should a method ran several times in a PHP class be cached to a class variable instead?

In PHP I know many people will use a class to SET and GET session variables, I am doing this now in many classes, I need to know if I am doing it wrong though. So for example lets pretend I have A class that need to use this $session->get('user_id') Which gets this value $_SESSION['user_id'] Now in this class if I have 15 metho...

Virtual tables on anonymous classes

I have something similar to this in my code: #include <iostream> #include <cstdlib> struct Base { virtual int Virtual() = 0; }; struct Child { struct : public Base { virtual int Virtual() { return 1; } } First; struct : public Base { virtual int Virtual() { return 2; } } Second; }; int main() { Child child; ...

How does this PHP know which array key/values to use?

Below is part of a PHP database class someone else wrote, I have removed about 80% of it's code, all the un-related code to my question has been removed and just the amount remains that allows me to test this class without actually hitting a real database. This class has a couple methods that let you set a key and value it then turns ...

How to append div and add class where div id is the same as td value with jquery?

I have the following two HTML which is generated by PHP. I want to append the second one to the first table td. I want to add class="date_has_event" to td if there are events. Each event has number which is the date in div id. I am using jquery, but I am not sure. Could anyone tell me how to approach this one please? HTML <tr> <td>1...

Ruby class variables

The ruby class-instance stuff is giving me a headache. I understand given this... class Foo @var = 'bar' end ...that @var is a variable on the created class's instance. But how do I create a sub-class overridable class variable? Here is an example of what I would do in Python: class Fish: var = 'fish' def v(self): return sel...

questions about objective-c class methods

I know that class variables are declared in memory (as opposed to on the stack) when the class is initialized, and I know how class methods are basically used. But I have some questions about class methods that aren't answered in the basic documentation. Are class method also declared in memory? What about any object declared within the...

How do you use the non-default constructor for a member?

I have two classes class a { public: a(int i); }; class b { public: b(); //Gives me an error here, because it tries to find constructor a::a() a aInstance; } How can I get it so that aInstance is instantiated with a(int i) instead of trying to search for a default constructor? Basically, I want to con...

Cocoa / Objective-C: Access a (Boolean) variable in different Classes

Hey People^^ Situation: Noob / Xcode 3.1 I have an AppView (NSView subclass) and an AppController (NSObject subclass) in AppView.h i declare a boolean (BOOL: booleanDraw), which i set to 'NO' in AppView.m When a button is clicked it 'launches' an action (AppController .h/.m) now i want to change booleanDraw to YES when the button is ...

cocoa / Objective-C: Cross- Class Variables

Hey i was searching for a solution for my problem and i nearly have it just one tiny bit... I have a NSView subclass (AppView) and a NSObject subclass (AppController) In AppView i declare a boolean with the @property than i use @synthesize and than in AppController i want to access it: i found this: (in the implementation) AppView *ob...

Why isn't operator overloading available for classes in Delphi?

I've always wondered about this for a bit, but why is operator overloading not available for classes in Delphi? I remember reading an answer once while on the run, and it said it would come in conflict with something, but I can't remember much. As far as I can tell, only the implicit operator may cause a bit of problems since classes ar...

How can you share ivars between classes.?

In one classes .h i have NSMutableArray *rountines; and in another classes .m i want to do something like this [routines addOject:@"Hello]; the other class is an ModalViewController type set up. So, in essence i'd like the .m file of the MVC to be able to read, and edit and do other things to the ivars i declare in the header. ...

PHP class problems. Cant call another class?

I have a class file: class_xx.php. And then a function file: function_xxx.php In my function_xxx.php: require_once('class_xx.php') ... // after few next lines $object = new class_xx1($arg1, $arg2); But it gives me: Fatal error: Class 'class_xx1' not found in "some_path" on line "1XX3" [sorry i cant exposed the codes yet], any ide...

How do I declare an attribute in Python without a value?

In C# I would go: string UserName; string Password; But now, in Python: class User: UserName Password I recieve an error that UserName isn't defined. I can't declare a variable without a variable? ...

Why can't Delphi records have inheritance?

Something I've wondered for a long time: why aren't Delphi records able to have inheritance (and thus all other important OOP features)? This would essentially make records the stack-allocated version of classes, just like C++ classes, and would render "objects" (note: not instances) obsolete. I don't see anything problematic with it. T...

Easiest way to set a PHP CONSTANT in 1 file and access it everywhere?

I have asked similar questions before but here is a full demo example code. In PHP how can I access a Constant value that is set in a config file and then included into every page, Including CLASS FILES? I realize this is some sort of scope issue so what is the best way to access this constant inside my class file below without passi...

Will PHP load all files references in a page?

I am working on a cache class, I would like to be able to set and get cached items from 5 different storage mediums. Memcache, APC cache, file cache, sessions, cookies. Maybe even a 6th (database could be added as a 6th). My goal is to make this flexible enough that I can use it in the future on many projects very easily (portable). ...