473,395 Members | 1,972 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Using a function within a class

I have written a class (and it works!).
Now I want to tidy the code a bit by separating some subroutines and I
get a "Fatal error: Call to undefined function:"

e.g.
class Fred{
function Fred(){
//constructor

do_this();
}

function do_this(){ blah blah }
}

Please can someone tell what I'm doing wrong? If I use
function_exists(do_this) it returns false.
I've tried putting the function as the first block in the class.
I've tried calling it as a method e.g. $this->do_this();

PHP 4.3.9 on IIS (localhost)

Thanks in advance

Pete
Oct 19 '05 #1
2 6302
Bloke Smith wrote:
I have written a class (and it works!).
Now I want to tidy the code a bit by separating some subroutines and I
get a "Fatal error: Call to undefined function:"

e.g.
class Fred{
function Fred(){
//constructor

do_this();
}

function do_this(){ blah blah }
}

Please can someone tell what I'm doing wrong? If I use
function_exists(do_this) it returns false.
I've tried putting the function as the first block in the class.
I've tried calling it as a method e.g. $this->do_this();

PHP 4.3.9 on IIS (localhost)

Thanks in advance

Pete


$this->do_this();

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Oct 19 '05 #2
On Wed, 19 Oct 2005 18:23:36 -0500, Jerry Stuckle
<js*******@attglobal.net> wrote:
Bloke Smith wrote:
I have written a class (and it works!).
Now I want to tidy the code a bit by separating some subroutines and I
get a "Fatal error: Call to undefined function:"

e.g.
class Fred{
function Fred(){
//constructor

do_this();
}

function do_this(){ blah blah }
}

Please can someone tell what I'm doing wrong? If I use
function_exists(do_this) it returns false.
I've tried putting the function as the first block in the class.
I've tried calling it as a method e.g. $this->do_this();

PHP 4.3.9 on IIS (localhost)

Thanks in advance

Pete


$this->do_this();


Dang! I coulda sworn I tried that yesterday and it didn't work. I must
have had two errors.
Thanks a lot.

Oct 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Martin Lucas-Smith | last post by:
I have a class from within which other classes are called. In the constructor, I want to create an instance of a database connection, so that this database can be called elsewhere. <?php #...
28
by: Daniel | last post by:
Hello =) I have an object which contains a method that should execute every x ms. I can use setInterval inside the object construct like this - self.setInterval('ObjectName.methodName()',...
6
by: Alex Fitzpatrick | last post by:
Just by way of introduction, I'm currently the principal developer and maintainer of the a JavaScript editor plug-in for Eclipse. https://sourceforge.net/projects/jseditor/ The plug-in as it...
2
by: Jacek Dziedzic | last post by:
Is it valid to use a "using namespace foo" (as opposed to using foo::bar which I'm sure is legal) within a class declaration? My compiler rejects it, but I've been told it's valid. Can anyone...
12
by: Joe | last post by:
Hello All: Do I have to use the LoadControl method of the Page to load a UserControl? I have a class which contains three methods (one public and two private). The class acts as a control...
7
by: oopsbabies | last post by:
Hello everyone, I am using Apache 1.3.33 as the web server and PHP version 4.3.10. My machine is using Windows XP 2002 professional edition which comes with a Windows firewall. I am using McAfee...
0
by: peridian | last post by:
Hi, I wanted a web page where I could post code to, and have it appear in coloured formatting based on the context of the code. Most of the techniques I have seen for this involve complex use...
14
by: Mohamed Mansour | last post by:
Hey there, this will be somewhat a long post, but any response is appreciated! I have done many PInvoke in the past from C++ to C#, but I did PInvoke within C# not C++/CLI. Can someone explain...
0
by: J. Cliff Dyer | last post by:
On Thu, 2008-11-13 at 11:19 -0600, Chris Mellon wrote: He is using an object. Specifically, he's using a function object. Though perhaps you meant put it into a class. Here are a few essays...
15
by: r0g | last post by:
Hi There, I know you can use eval to dynamically generate the name of a function you may want to call. Can it (or some equivalent method) also be used to do the same thing for the variables of a...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
jinu1996
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...
0
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...
0
agi2029
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,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.