Solved

General Question..

Posted on 2006-07-16
5
255 Views
Last Modified: 2012-05-05
<?php
$author = "<?php the_author_email() ?>";
?>
<div class="<?php if ($author->the_author_email == "email1@gmail.com") echo 'christopher_comment'; else if ($author->the_author_email =="email2@gmail.com") echo 'christine_comment'; ?>"><?php } ?>

This should echo either christopher_comment or christine_comment inot the class="" but it's not...

What is happening is this..
<div class="">      


Now.. how could I just check to see if $author is holding the correct email value.. and also.. does anybody see anything wrong with my statements?
0
Comment
Question by:cstormer
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 35

Expert Comment

by:Raynard7
ID: 17118657
Your tags look confused - for example if you are trying to put the author into a php value - using a function the_author_email() then you would do


<?php
$author = the_author_email();
?>


Also = author does not look like a class - so the_author_email does not look like a property, I wold try

<div class="<?php if ($author == "email1@gmail.com") echo 'christopher_comment'; else if ($author =="email2@gmail.com") echo 'christine_comment'; else echo $author; ?>">

But it is better form to actually put the php value in a php block rather than in the middle of html. ie

<?php
$author = the_author_email();

if ($author == "email1@gmail.com") {
    $classVal =  'christopher_comment';
} else if ($author =="email2@gmail.com") {
    $classVal =  'christine_comment';
} else {
    $classVal = $author;
} // end if
?>

<div class="<?php echo $classVal; ?>">

0
 

Author Comment

by:cstormer
ID: 17118862
This seems to be a something tha twould work... except the

<?php
$author = the_author_email();
?>

Seems to be echoing the value of the_author_email to the screeen...

0
 
LVL 35

Expert Comment

by:Raynard7
ID: 17118877
the_author_email must be a function that you have defined, what you should do is remove any echo commands in this function, or change them to echo or not depending if you send true or false to the function.

ie

function the_author_email($boolVal) {
  if($boolVal) {
     echo $authorString;
  }
  return $authorString;
}
0
 

Author Comment

by:cstormer
ID: 17118889
the problem is the_author_email is a fucntion defined by wordpress (blogging software) it is hardwired into the code, changing it will change a ton of stuff... so I do know that it knows the correct value.. but I need to store the value it will echo out.. into a variable..

is there a way to take what it would echo (the email) and add it to a variable.. because if the code it produces prints the email to the screen... any thoughts?

0
 
LVL 35

Accepted Solution

by:
Raynard7 earned 500 total points
ID: 17119015
Without changing it I think it would be difficult.

However - one quick and easy work around would be to surround the code that calls it in html comment tags.

ie

<!--<?php
$author = the_author_email();
?>-->

Which means it will be output would be sent to the browser but as it would be commented it would not display
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question