Don's original declaration is correct.  It refers to a constructor.  Without
a parameter, the new() will fail.

-----Original Message-----
From: Stampe, Lars [mailto:[EMAIL PROTECTED]]
Sent: Friday, March 22, 2002 7:53 AM
To: 'Don'; php
Subject: RE: [PHP] A Newbie needs help with his first Class


And then replace

$global = new Globals("/staging_area/phase-2/");

with

$global = new Globals;
$global->someting else("/staging_area/phase-2/");

Lars

-----Original Message-----
From: Stampe, Lars [mailto:[EMAIL PROTECTED]]
Sent: 22 March 2002 13:46
To: 'Don'; php
Subject: RE: [PHP] A Newbie needs help with his first Class


Hi,

Try and rename the function in your class to something else that the class
name, and let me know what happens!

Lars

-----Original Message-----
From: Don [mailto:[EMAIL PROTECTED]]
Sent: 22 March 2002 13:01
To: php
Subject: [PHP] A Newbie needs help with his first Class


Hi,

I'm trying to write my first class.  Here is the code contained in a file
called "globals.php":

<?PHP
class Globals
{
  var $gDISPLAY  = 1;        /* Display graphic - no rollover */
  var $gROLLOVER = 2;     /* Display graphic with rollover */
  var $root_path;                /* Path to document root directory */
  var $relative_path;            /* Path from document root to relative root
directory */

  function Globals($start_dir)
  {
    if ( strlen($DOCUMENT_ROOT) == 0) {
       $this->$root_path = "/";
    } else {
       $this->$root_path = $DOCUMENT_ROOT;
    }
    $this->$relative_path = $this->$root_path . $start_dir;
  }
}

$global = new Globals("/staging_area/phase-2/");
?>


Within my html page, I am tesing the class by trying the following:
<?php
require("globals.php");
echo $global->root_path . "<br>";
echo $global->relative_path . "<br>";
?>

However, nothing is being written to my browser.  Is there a problem with
the code?

Thanks,.
Don

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to