I may have more of a design problem, but here goes.
I have a class that has 3 methods. One method simply calls the other
two. I wanted to make the class static, and to do this in php, you
just have to make the function static. So I did that for all three
functions. But now I cannot call the other two functions from the
first function.
What do I need to do to make the one function in the class call the
other 2. The only way I know right now, is to not make any of the
functions static. 2 1237
On Thu, 03 Jan 2008 18:03:36 +0100, Anthony Smith <mr******@hotma il.com>
wrote:
I may have more of a design problem, but here goes.
I have a class that has 3 methods. One method simply calls the other
two. I wanted to make the class static, and to do this in php, you
just have to make the function static. So I did that for all three
functions. But now I cannot call the other two functions from the
first function.
self::functionn ame();
<?php
class foo{
static function bar(){
self::foz();
self::baz();
}
static function foz(){echo 'hello';}
static function baz(){echo ', world';}
}
foo::bar();
?>
--
Rik Wasmus
On Jan 3, 11:17 am, "Rik Wasmus" <luiheidsgoe... @hotmail.comwro te:
On Thu, 03 Jan 2008 18:03:36 +0100, Anthony Smith <mrsmi...@hotma il.com>
wrote:
I may have more of a design problem, but here goes.
I have a class that has 3 methods. One method simply calls the other
two. I wanted to make the class static, and to do this in php, you
just have to make the function static. So I did that for all three
functions. But now I cannot call the other two functions from the
first function.
self::functionn ame();
<?php
class foo{
static function bar(){
self::foz();
self::baz();
}
static function foz(){echo 'hello';}
static function baz(){echo ', world';}}
foo::bar();
?>
--
Rik Wasmus
Thanks you very much Rik. I have a follow up. Let say in my class, I
would like to include a properties file:
require_once 'website.inc'; // has a value called $var_from_file in
it.
I would like to use a value from this file.
static function foz(){echo $var_from_file; }
How would I do that? This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Thomas Matthews |
last post by:
Hi,
I have three classes:
Category
Author
Publisher
Each of these classes stores its information into
a database table of <ID, text>. (They are fields
that have a foreign key.) There is only one
table for each instance of these classes (IOW,
|
by: Bruno Rodrigues |
last post by:
Hi
In a class with simple methods like:
Products.Insert(string name, string desc)
Products.Update(int id, string name, string desc)
Products.Delete(int id)
What is better? Static or common methods? This objects do not need
instances.
|
by: Jay |
last post by:
Why are there static methods in C#. In C++ static was applied to data only
(I believe) and it meant that the static piece of data was not a part of the
object but only a part of the class (one copy of data as opposed to multiple
instances of the class)
C# is now applying the static concept to methods. Why?, I thought that only
one copy of the methods were loaded into memory not matter how many
instances were created. Is this different...
|
by: Picho |
last post by:
Hi all,
I popped up this question a while ago, and I thought it was worth checking
again now... (maybe something has changed or something will change).
I read this book about component oriented design (owreilly - Juval Lowy),
and it was actually very nice.
The book goes on about how we should use Interfaces exposure instead of
classes (this is my terminology and english is not my language so I hope you
understand what I'm on about...).
|
by: Kevin Prichard |
last post by:
Hi all,
I've recently been following the object-oriented techiques discussed
here and have been testing them for use in a web application. There is
problem that I'd like to discuss with you experts.
I would like to produce Javascript classes that can be "subclassed"
with certain behaviors defined at subclass time. There are plenty of
ways to do this through prototyping and other techniques, but these
behaviors need to be static and...
| |
by: MSDNAndi |
last post by:
Hi,
I have a baseclass (non-static) with some static and some non-static
methods/fields/properties.
In the baseclass in one of the static methods I need to do something like
"
somelogic
....
CallToStaticMethod();
|
by: DBC User |
last post by:
I have a class with bunch of static methods. I could regourp all the
static methods into seperate 3 or 4 classes. I was thinking about using
Singlton pattern for all these 4 classes so that it behaves like static
still class. But my concern is, when going from static to singlton, I
need to add one more line to make sure the class is instantiated.
Am I going in right direction?
Thanks for the help.
|
by: Steve Richter |
last post by:
in a generic class, can I code the class so that I can call a static
method of the generic class T?
In the ConvertFrom method of the generic TypeConvert class I want to
write, I have a call to the static Parse method of the conversion
class.
if (InValue is string)
return T.Parse((string)InValue);
else
return base.ConvertFrom(context, culture, InValue);
|
by: Steffen Bobek |
last post by:
Extension methods are made for use with instances. I'd like to "misuse" them
as static methods, too. Let me tell you my ambition:
I use an extension method to serialize objects somehow like this:
MyObject obj = new MyObject();
obj.ToXmlFile("some directory\\some file.xml");
The method "ToXmlFile" is defined elsewhere far apart from MyObject to work
for all objects:
|
by: Rene |
last post by:
Hi,
I was wondering if anyone could tell me why extension methods must be
declared on static classes. I mean, why not allowing them to be declared as
static methods in regular instance classes?
In case you are wondering, I am only curious to find out the reason for this
limitation. I don't really have a need to declare extension method on non
static classes. I am just curious.
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |