StrangeWill Posted November 2, 2006 Share Posted November 2, 2006 <?phpclass Student{ var $varName, $varPhone, $varTest; function Student() { }}?><?php$Kyle = new Student();$Kyle->$varName = 'kyle';$Kyle->$varPhone = 'phone number';$Kyle->$varTest = 'test';?>Name: <?=$Kyle->$varName?><br />Phone: <?=$Kyle->$varPhone?><br />Test: <?=$Kyle->$varTest?>All of them print 'test'No matter what, it always prints the last variable entered! Gah!Using PHP 4.4.2 Link to comment https://forums.phpfreaks.com/topic/25975-new-to-php-classes-variable-errors/ Share on other sites More sharing options...
trq Posted November 2, 2006 Share Posted November 2, 2006 [code=php:0]<?php$Kyle = new Student();$Kyle->varName = 'kyle';$Kyle->varPhone = 'phone number';$Kyle->varTest = 'test';?>Name: <?=$Kyle->varName?>Phone: <?=$Kyle->varPhone?>Test: <?=$Kyle->varTest?>[/code] Link to comment https://forums.phpfreaks.com/topic/25975-new-to-php-classes-variable-errors/#findComment-118684 Share on other sites More sharing options...
StrangeWill Posted November 2, 2006 Author Share Posted November 2, 2006 Awesome, thanks, I see what I was doing wrong now :P Link to comment https://forums.phpfreaks.com/topic/25975-new-to-php-classes-variable-errors/#findComment-118686 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.