Problem with class constructor

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
I am witting a project that needs to have unique names for each detail
line.  To achieve this I use the day and line number as part of the
name.  Given my code I would expect that I would get something like
<label for='hrs'>Hours<input type='text' name='hrs1_1' style='width:2em'
/></label>. My result is <label for='hrs'>Hours<input type='text'
name='hrs_' style='width:2em' /></label> as you can see the name
attribute does not have the variable portion.  I can see that the
parameters passed are comming in to the constructor correctly but the
member variables of my class are not being set.  I can't see why, it
must be something real simple.

I have declared the class as follows:

class clsBlnkDetail
    var $mTs;
    var $mDay;
    var $mLine;
    function clsBlnkDetail($Day,$Line,$sheet="none")
        //Debug code
        //End Debug code
        if ($sheet != "none")
            if($day > 6)
                echo "There are only 7 days in a week";

            //member variable should be set here

            //Debug code
            fwrite($fp,$this->$mDay." ".$this->$mLine);
              //End Debugg code

    function MkName()
    function Build()
        //echo "Blank detail line<br />";
        echo "<label for='hrs'>Hours";
        echo "<input type='text' name='$widgitName; style='width:2em' />";
        echo"</label> <br />";

Re: Problem with class constructor

Charles Russell wrote:
Quoted text here. Click to load it
Quoted text here. Click to load it
Don't forget that variable names are case sensitive. This test will not
trigger when $Day > 6; the code will also produce a warning when
error_reporting is set to E_ALL.

Quoted text here. Click to load it

You're still in the first if() block, so if you didn't pass a non-"none"
$sheet parameter, this will never be executed and your member variables
will never be set.

I do, however, get the expected results with your code when passing a

$foo = new clsBlnkDetail( 1, 1, 'notblank' );

-- brion vibber (brion @

Site Timeline