Current location: Hot Scripts Forums » Programming Languages » PHP » OOP problem


OOP problem

Reply
  #1 (permalink)  
Old 02-26-06, 10:23 PM
lcwei81 lcwei81 is offline
Newbie Coder
 
Join Date: Jun 2005
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
OOP problem

Can anybody help me with this?
<?
class Msg{
function Msg(){
$this->msg = '';
}
function defineMsg(){
$this->msg = "testing";
$true = $this->msg;
$this->getMsg($true);
}
function getMsg($true){
//$result ="my result" .$true ;
return $true;
}
/*
function display(){
$this->getMsg
}*/
}

$smsg = new Msg;

echo $smsg->defineMsg();
?>

Can anyone point out what's wrong with this?
Thanks.
Reply With Quote
  #2 (permalink)  
Old 02-27-06, 04:42 AM
NeverMind's Avatar
NeverMind NeverMind is offline
Community VIP
 
Join Date: Aug 2003
Location: K.S.A
Posts: 2,257
Thanks: 0
Thanked 2 Times in 1 Post
nothing wrong with this code syntax-wise.
it's just that it's horribly defined!
PHP Code:

<?php

class Msg
{
   function 
Msg()
   {
      
$this->msg '';
   }

   function 
defineMsg()
   {
       
$this->msg "testing";
       
$true $this->msg;
       
$this->getMsg($true);
   }

    function 
getMsg($true)
    {
        
//$result ="my result" .$true ;
        
return $true;
    }
/*
    function display()
    {
       $this->getMsg();
    }*/
}

$smsg = new Msg;

echo 
$smsg->getMsg('a very bad way and indirct way to print me');
?>
__________________
PHPSimplicity
We don't need a reason to help people - Zidane [FF9]
Reply With Quote
  #3 (permalink)  
Old 02-27-06, 11:48 PM
lcwei81 lcwei81 is offline
Newbie Coder
 
Join Date: Jun 2005
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
As i am a newbie for OOP, I find it not easy to master it.
thanks for ur "critic". I wanna to get the message display without go through echo $msg->getMsg('text').
I have managed to do it. thanks anywhere.

Last edited by lcwei81; 02-27-06 at 11:52 PM.
Reply With Quote
  #4 (permalink)  
Old 02-28-06, 03:33 AM
NeverMind's Avatar
NeverMind NeverMind is offline
Community VIP
 
Join Date: Aug 2003
Location: K.S.A
Posts: 2,257
Thanks: 0
Thanked 2 Times in 1 Post
Quote:
Originally Posted by lcwei81
As i am a newbie for OOP, I find it not easy to master it.
thanks for ur "critic". I wanna to get the message display without go through echo $msg->getMsg('text').
I have managed to do it. thanks anywhere.
You are right, I am sorry I was not friendly
but glad you could work it out!
__________________
PHPSimplicity
We don't need a reason to help people - Zidane [FF9]
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Weird mysql_query and Smarty problem Canglan PHP 3 11-15-05 08:49 PM
Problem with if statements filth PHP 1 08-04-05 09:18 PM
A Language filter problem, and a problem with a for loop querying my database. . . Spreegem PHP 6 05-08-05 11:03 AM
Count problem kasic ASP.NET 1 10-20-04 12:23 AM
Asp and Microsoft Access 2002 problem gop373 ASP 2 10-06-04 09:13 AM


All times are GMT -5. The time now is 06:35 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.