SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Apr 2001
    Location
    Norway
    Posts
    0
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Class layout problem

    I want to do this. I create the object like this:
    PHP Code:
     include_once("classes/Template.php" );$tpl_file = new Template("login" ); 
    PHP Code:
    <?
    class Template
    {
     var 
    $contents;
     
     function 
    Template($tpl)
     {
      
      
    $filename "templates/$tpl.tpl";
      
      
    $handle fopen ($filename,"r");
      
    $contents fread ($handlefilesize ($filename));
      
    $this->contents $contents;
      
    fclose ($handle);
      
     }
     function 
    getContent() {
      return 
    $this->$contents
     }
    }
    ?>
    What is the error in this ? It look very java alike, and also found a similar example on phpbuilder.

    Notice: Undefined variable: contents in C:\www\mm\classes\Template.php on line 19

    When doing print $contents inside the function, it returns the content of the file...
    Last edited by are; May 27, 2003 at 00:33.
    Regards,
    Are

  2. #2
    SitePoint Member
    Join Date
    Apr 2001
    Location
    Norway
    Posts
    0
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi

    Solved...shouldn´t have the $ in contents...
    Regards,
    Are


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •