Hi,
This may be the dumbest question ever, but in the following code (using
PHP 4.3.8) how do I call b() from within a()?
class test {
function a() {
print "a called";
b();
function b() {
print "b called";
}
}
}
using "b()" (as in the code above) doesn't work, neither does $this->b()
or test::b(), so how do I call it?
Thanks!
Andrew 3 2419
Andrew Boothman wrote: Hi,
This may be the dumbest question ever, but in the following code (using PHP 4.3.8) how do I call b() from within a()?
class test { function a() { print "a called"; b();
function b() { print "b called"; } } }
using "b()" (as in the code above) doesn't work, neither does $this->b() or test::b(), so how do I call it?
You will need to define the function before calling it.
Regards,
Per
"Andrew Boothman" <an************ *@blueyonder.co .uk> wrote in message
news:JF******** *************** @news-text.cableinet. net... This may be the dumbest question ever, but in the following code (using PHP 4.3.8) how do I call b() from within a()?
class test { function a() { print "a called"; b();
function b() { print "b called"; } } }
using "b()" (as in the code above) doesn't work, neither does $this->b() or test::b(), so how do I call it?
first, you would need to define function b prior to calling it. Even when
you would do so, than you would be able to call function a only once, since
second call to a would try to define function b() which would be by that
time allready defined.
In php there is no notion of local function, as you would know it from other
languages like Pascal. The construct you are using might misslead you, that
you are defining function b local to function, but you are not, you are just
within code of a executing statement that in effect defines global function
b().
rush
-- http://www.templatetamer.com/
Per Gustafsson wrote: Andrew Boothman wrote: Hi,
This may be the dumbest question ever, but in the following code (using PHP 4.3.8) how do I call b() from within a()?
class test { function a() { print "a called"; b();
function b() { print "b called"; } } }
using "b()" (as in the code above) doesn't work, neither does $this->b() or test::b(), so how do I call it?
You will need to define the function before calling it.
No, the function needs to be defined before you can call it - that's not the
same thing at all - unlike 'C', PHP will quite happily call functions
defined below its invocation in the source file.
To call a METHOD within an OBJECT, you need to instantiate the object and
reference the method e.g.
class test {
function a() {
print "a called";
$this->b(); // ********
function b() {
print "b called";
}
}
} using "b()" (as in the code above) doesn't work, neither does $this->b() or test::b(), so how do I call it?
I guess you didn't create an instance -
$testObj = new test;
$testObj->a();
HTH
C. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Joel Thornton |
last post by:
Is it possible to call a user-defined function without prefixing it
with 'dbo.' within a SELECT clause somehow? Just curious; it's not a
big issue but just a stylistic one for me.
Thanks!
Joel Thornton ~ <groups@joelpt.eml.cc>
|
by: Red Ogden |
last post by:
The following script returns an error saying document.all is null or
not an object when I try to call the write_layer function more than
once within the same else statement i.e.:
else {
write_layer('layer1', '<i>1st new base field</i>');
write_layer('layer2', '<i>2nd new base field</i>');
Id be grateful if anyone can advise me on how to get it to call
multiple times inserting dynamic content in various <div> layers
|
by: joseluismarchetti |
last post by:
Hello everybody,
Although I am sure this is an important question for this group, I
am not sure this question belongs to this group and I will be
happy to move it to the correct one after you point it to me.
Direct question:
How can I know if a function is defined in more than one static
library that I am using to link ?
|
by: Angel |
last post by:
Hi again,
I'm trying to call functions from a proprietary DLL but it's turned out to
be more difficult than I thought.
I have this W32.DLL which was written in C by USPS. They don't provide the
code so I only have the documentation.
I'm trying to call a function called z4date that, according to the docs,
returns the date as "an 8-byte character string in the "YYYYMMDD" format".
When I run it with this code I've written , I get "Can not...
|
by: Zeebra3 |
last post by:
Here goes: I have a web form with several asp:dropdownlists, with
which, when selection is changed I want to fire an event defined in
some clientside js.
The content of the clientside code is dependant on data collected in
the code behind on the server. I have set AutoPostback to false for
the controls and added lines such as
cboMyCombo1.Attributes.Add("onchange", "MyCombos_OnChange('1')");
in the Page_Load event, which is rendered OK...
| |
by: Adam Witney |
last post by:
I'd like to be able to have a PL/pgSQL function defined as SECURITY DEFINER,
but still have access to the calling username within the function. Is this
possible?
I could pass current_user as a parameter, but of course this could easily be
bypassed.
Is there a way of coding this?
Thanks for any help
|
by: M B HONG 20 |
last post by:
Hi all -
I am working on a web application and have run into a problem. From a
main window (Window1) I open a child window (Window2), and from that
child window I open a grandchild window (Window3). I need to call a
funcion that resides on Window1 from Window3. I do this successfully
by calling a function with window.opener on Window3, which calls a
function with window.opener on Window2, which calls a function on
Window1.
My...
|
by: torbs |
last post by:
I have an defined an object with a method called loadMovie that use a
method - SetUrl- in an embedded quicktime object. It is embedded using
the object tag, but I have also tried the embed tag.
The problem is this. Although Firefox recognise the quicktime object as
a HTMLObjectElement, it does not give me access to it methods from
within my object. I have created a seperate function and when I in that
function type...
|
by: tuka |
last post by:
Hi,
I have 2 methods defined within a javascript objects
that I would like to call in a third function within the same object.
In the example below, func3 works well in FF but in IE7 it breaks.
Any suggestions about how this may work ? I am sure this has to do
with notation.
I am calling the methods statically - so not instantiating a objects
first.
|
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: 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: 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.
| |