0

I got a simple php page like this:

<?php
include 'config.php';
include 'lib.php';
header("Content-type: text/html; charset=UTF-8");

?>

<html>
    <head>
        <title>view states</title>
        <link rel="stylesheet" type="text/css" href="css/style.css"/>
        <script type="text/javascript" src="jquery-1.8.2.min.js"></script>
    </head>

    <body>

    <div id="container">
        WTF?
    </div>

    </body>

</html>

when i have the code below in my lib.php, my dom just contains a head and body. The title is gone, the div container is gone and the text 'wtf?' also.

What's wrong?

class State {
  $id;
  $ip;
  $state;
  $date;
  $played;

  function __construct($id, $ip, $state, $date, $played) {
     $this->$id = $id;
     $this->$ip = $ip;
     $this->$state = $$state;
     $this->$date = $date;
     $this->$played = $played;
  }


}
clankill3r
  • 9,146
  • 20
  • 70
  • 126

1 Answers1

0

Turn on error reporting and the problem becomes quite obvious. You've failed to declare your class variables correctly

<?php
class State {
  protected $id;
  protected $ip;
  protected $state;
  protected $date;
  protected $played;

  function __construct($id, $ip, $state, $date, $played) {
     $this->id = $id;
     $this->ip = $ip;
     $this->state = $state;
     $this->date = $date;
     $this->played = $played;
  }


}
Neil Aitken
  • 7,856
  • 3
  • 41
  • 40