|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2006-05-25 05:50 UTC] baby dot bjorn at yahoo dot com
[2006-05-25 06:42 UTC] johannes@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Dec 02 13:00:01 2025 UTC |
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