Thread: Error in code

    #1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2013
    Posts
    12
    Rep Power
    0

    Error in code


    <?php

    class Person
    {
    var $name;
    function set_name($data)
    {
    $this->name=$data;
    }
    function __construct ($data)
    {
    $this->$data;
    echo "constructing",$data,",,,,<br>";
    }
    public function get_name()
    {
    return $this->name;
    }
    function __destruct()
    {
    echo "destructing",$this->name,".....<br>";
    }
    }
    $dn=new Person("Dan");
    echo"the name is" ,$dn->get_name(),"......<br>";

    ?>



    im getting an error message while i was running this code.can anyone please tell me why that error come??thanks in advance
    this is the error

    ( ! ) SCREAM: Error suppression ignored for
    ( ! ) Notice: Undefined property: Person::$Dan in C:\wamp\www\dwer\woo17.php on line 19
    Call Stack
    # Time Memory Function Location
    1 0.0011 370784 {main}( ) ..\woo17.php:0
    2 0.0011 371024 Person->__construct( ) ..\woo17.php:31
  2. #2
  3. Did you steal it?
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    13,961
    Rep Power
    9397
    PHP Code:
    $this->$data
    It's wrong, but it's a useless statement so it shouldn't even be there. Seems like you should be calling set_name()?

IMN logo majestic logo threadwatch logo seochat tools logo