Solved

General Question..

Posted on 2006-07-16
5
260 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

Don't Cry: How Liquid Web is Ensuring Security

WannaCry is just the start. Read how Liquid Web is protecting itself and its customers against new threats.

Question has a verified solution.

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

Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

707 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