#37584 [Com]: is a problem with the constructor functions
| From: | baby dot bjorn at yahoo dot com | Date: | Thu, 25 May 2006 05:50:00 +0000 |
| Subject: | #37584 [Com]: is a problem with the constructor functions | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-97578@lists.php.net to get a copy of this message | ||
ID: 37584
Comment by: baby dot bjorn at yahoo dot com
Reported By: daniel dot forero at hotmail dot com
Status: Open
Bug Type: Class/Object related
Operating System: windows, linux
PHP Version: 5.1.4
New Comment:
It's $this->nombre not $this->$nombre
Previous Comments:
------------------------------------------------------------------------
[2006-05-25 00:56:38] daniel dot forero at hotmail dot com
Description:
------------
I have a class that have a constructor function, you can study the
code, the result of execute the script is diferent for the expect
Reproduce code:
---------------
<?php
class usuario
{
var $nombre;
var $edad;
var $cargo;
function set_name($name)
{
$this->$nombre=$name;
}
function usuario()
{
$this->$nombre="(Undefined)";
$this->$edad=0;
$this->$cargo="(not a charge)";
}
}
$daniel = new usuario;
$daniel->set_name("daniel");
echo $daniel->$nombre;
echo '<br>';
echo $daniel->$edad;
echo '<br>';
echo $daniel->$cargo;
?>
Expected result:
----------------
daniel
0
(not a charge)
Actual result:
--------------
daniel
daniel
daniel
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=37584&edit=1