470,874 Members | 1,533 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,874 developers. It's quick & easy.

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 6198
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Martin Lucas-Smith | last post: by
28 posts views Thread by Daniel | last post: by
6 posts views Thread by Alex Fitzpatrick | last post: by
2 posts views Thread by Jacek Dziedzic | last post: by
12 posts views Thread by Joe | last post: by
7 posts views Thread by oopsbabies | last post: by
reply views Thread by J. Cliff Dyer | last post: by
15 posts views Thread by r0g | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.