Guest yquetales Posted June 29, 2010 Report Share Posted June 29, 2010 Say I have a class person with a method that returns some value, for instance an email address. <?php something like class person{ var $email; function set_email($new_email){ $this->email = $new_email; } function get_email(){ return $this->email; } } ?> if I call this method from a view file say <?php $rodrigo = new person(); $rodrigo->set_email("rodrigo@hotmail.com"); I can display the email using echo "his email is :".$rodrigo->get_email(); but what if I want to retrieve his email from a database for instance to use it in a link: for example if I want to do this <a href=website.com/index.php?content=contact&email=$email>Contact</a> where $email should be rodrigo's email. What should I do to get rodrigo's email from the method get_email(); into a variable?? ?> Maybe this is a very simple question, but I appreciate your help. Thanks Quote Link to comment Share on other sites More sharing options...
jstern Posted June 29, 2010 Report Share Posted June 29, 2010 $email = $rodrigo->get_email(); $email now contains his email address just echo it out. <a href=website.com/index.php?content=contact&email=<?php echo $email; ?>>Contact</a> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.