What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Skype & Technology » Tech Talk » [PHP] Quick Dumb Question: Classes

[PHP] Quick Dumb Question: Classes
Author: Message:
L. Coyote
Senior Member
****

Avatar
Captain Obvious

Posts: 981
Reputation: 49
39 / Male / Flag
Joined: Aug 2004
Status: Away
O.P. [PHP] Quick Dumb Question: Classes
Well, I'm programming again! (Yay, me!) But I'm so out-dated with everything, that I'm wondering about something...

Seeing as I can't test this until I finish more of it, I can only hope it'll work someday... So, the question is rather simple and I feel quite dumb to be asking this...

Suppose I have this:
code:
<?
class Something {

   function Something($sth, $blah) {

       if($blah == false) {

       $this->Something(functionToMakeSth(), true);

       }

   echo $this->property1;

   }

}
?>

Can I actually call the constructor again from inside the constructor? Will the changes reflect on $this later on?

For now, I'm leaving it that way until I can actually run the script. But it'd be nice to know if I'm doing it right, because I might need to do something similar in other classes. :wave:

This post was edited on 11-01-2006 at 05:42 AM by L. Coyote.

Hack, hack, hack!
Finally became a Systems Analyst! :spam:

11-01-2006 05:41 AM
Profile PM Find Quote Report
WDZ
Former Admin
*****

Avatar

Posts: 7106
Reputation: 107
– / Male / Flag
Joined: Mar 2002
RE: [PHP] Quick Dumb Question: Classes
Why don't you just make a little test script? That's what I do... :p
code:
<?php

class Something {
    var $property1 = 'property';
    function Something($sth, $blah) {
        if($blah == false) {
            $this->Something('test', true);
        }
        echo $this->property1;
        $this->property1 .= '2';
    }
}

$sth = new Something('test', false);
echo $sth->property1;

?>
That echoes "propertyproperty2property22" so I guess it works. :)

This post was edited on 11-01-2006 at 05:54 AM by WDZ.
11-01-2006 05:52 AM
Profile PM Web Find Quote Report
L. Coyote
Senior Member
****

Avatar
Captain Obvious

Posts: 981
Reputation: 49
39 / Male / Flag
Joined: Aug 2004
Status: Away
O.P. RE: [PHP] Quick Dumb Question: Classes
*sniff* WDZ!

quote:
Originally posted by WDZ
Why don't you just make a little test script? That's what I do... (Smilie)
Yeah, just great. I didn't even think about it. I was so worried about the fact that it's part of something big that I didn't think about putting that small piece into a test file. :P


It works great, WDZ. :bow: Thanks!

Hack, hack, hack!
Finally became a Systems Analyst! :spam:

11-01-2006 06:13 AM
Profile PM Find Quote Report
« Next Oldest Return to Top Next Newest »


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On