Say I have a class in PHP5 that looks like this:
class Hello{
function Moo() {
}
static function Boo() {
}
static function Loo() {
}
}
From within Moo(), how would I invoke Boo()? $this->Boo() seems to work, but
doesn't feel right. And if I'm in Loo(), there's no $this.
Is there a pseudo-classname akin to "parent" but refers to the current class
that can be used, or do we have to type in the class name everytime we call
a statis method? 2 5223
Can't you just use Boo()? (That's how one would do it in C++, haven't really
looked into PHP5 that heavily yet.)
Chung Leong wrote: Say I have a class in PHP5 that looks like this:
class Hello{
function Moo() { }
static function Boo() { }
static function Loo() { } }
From within Moo(), how would I invoke Boo()? $this->Boo() seems to work, but doesn't feel right. And if I'm in Loo(), there's no $this.
Is there a pseudo-classname akin to "parent" but refers to the current class that can be used, or do we have to type in the class name everytime we call a statis method?
Ok, I found the keyword through a little bit of trial and error. It's
"self":
class Hello {
function Moo() {
self::Boo();
}
static function Boo()
echo "Boo";
}
static function Loo() {
self::Boo();
}
}
Boo() alone would trigger an undefined function error.
Uzytkownik "Agelmar" <if**********@c omcast.net> napisal w wiadomosci
news:bu******** ****@ID-30799.news.uni-berlin.de... Can't you just use Boo()? (That's how one would do it in C++, haven't
really looked into PHP5 that heavily yet.)
Chung Leong wrote: Say I have a class in PHP5 that looks like this:
class Hello{
function Moo() { }
static function Boo() { }
static function Loo() { } }
From within Moo(), how would I invoke Boo()? $this->Boo() seems to work, but doesn't feel right. And if I'm in Loo(), there's no $this.
Is there a pseudo-classname akin to "parent" but refers to the current class that can be used, or do we have to type in the class name everytime we call a statis method?
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: David MacQuigg |
last post by:
I'm concerned that with all the focus on obj$func binding, &closures,
and other not-so-pretty details of Prothon, that we are missing what
is really good - the simplification of classes. There are a number of
aspects to this simplification, but for me the unification of methods
and functions is the biggest benefit.
All methods look like functions (which students already understand).
Prototypes (classes) look like modules. This will...
|
by: Jonathan Fine |
last post by:
Giudo has suggested adding optional static typing to Python.
(I hope suggested is the correct word.)
http://www.artima.com/weblogs/viewpost.jsp?thread=85551
An example of the syntax he proposes is:
> def f(this:that=other):
> print this
This means that f() has a 'this' parameter, of type 'that'.
And 'other' is the default value.
|
by: Xah Lee |
last post by:
in computer languages, often a function definition looks like this:
subroutine f (x1, x2, ...) {
variables ...
do this or that
}
in advanced languages such as LISP family, it is not uncommon to define
functions inside a function. For example:
|
by: Xah Lee |
last post by:
What are OOP's Jargons and Complexities
Xah Lee, 20050128
The Rise of Classes, Methods, Objects
In computer languages, often a function definition looks like this:
subroutine f (x1, x2, ...) {
variables ...
do this or that
}
|
by: Kenneth Baltrinic |
last post by:
This isn't a problem from the standpoint that its easy to work around.
However, I am very currious as to the correctness of this behavior.
I am developing an MDI application. In the application I have defined a
Toolbox class deriving from System.Windows.Forms.Form. I want only one
instance of this class to ever exist and for it to be displayable by calling
a static method of the class called Show(). To my surprise, my static
method is...
| |
by: garyusenet |
last post by:
I am at a loss with this. I tried to go back to basics, and start
learning all i didn't understand, starting at the top of the code file
generated by VS. But I can't seem to get any sort of start on this
problem, anything I read on the NET goes too far above my head to be of
any use.
For instance typical explanations say things like...
'The STAThreadAttribute marks a thread to use the Single-Threaded COM
Apartment if COM is needed'
|
by: =?Utf-8?B?QUEyZTcyRQ==?= |
last post by:
Am I correct in thinking that the <signatureof a function is its <syntax>
i.e. the arguments and the order in which they are specified when calling the
function?
|
by: Xah Lee |
last post by:
What are OOP's Jargons and Complexities
Xah Lee, 20050128
Classes, Methods, Objects
In computer languages, often a function definition looks like this:
subroutine f (x1, x2, ...) {
variables ...
|
by: K.J.Williams |
last post by:
Hello,
A friend and I want to learn PHP but we have two totally different
programming backgrounds.
I have experience with procedural programming in C, and he has
experience with Visual BASIC.
Well we wanted to know, what type of learning curve ( of difficulty )
we would have trying to learn PHP?
Also, What will be the most significant changes for us to adapt to? I
wanted to know if PHP is like
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |