Solved

IF evaluation not outputting as expected

Posted on 2006-06-20
3
216 Views
Last Modified: 2008-03-04
I am attempting to display some HTML conditionally depending on if it is during office hours. I'm sure that there is a more efficient way to write the following, but I'm not a PHP programmer, and I'm trying to write it as clearly as possible (for me).

The problem here is that the print function happens regardless of how the conditional statement is evaluated. The statement does evaluate as expected (if you print the output, True appears as 1 and false returns nothing), but the if statement prints regardless. I realize that the condition below doesn't make sense, but I wanted to ensure that it would output false in my test.

I need the print statement to happen only when the conditional statement evaluates to true.

<?php
// get current date
$current = getdate();
// turn it into strings
$current_hour = $current["hours"];
$current_minute = $current["minutes"];
$current_day = $current["wday"];

$switcher = ($current_hour < 7 && $current_hour < 17 && $current_day < 6);
if ($switcher == 1); {
print "<li><a href=# onclick=javascript:window.open('callme.html','callme','width=500,height=300,resizable=yes')><strong>Speak With an Advisor Now</strong></a></li>";
}
?>
0
Comment
Question by:BleuTango
  • 2
3 Comments
 
LVL 14

Accepted Solution

by:
ThG earned 500 total points
ID: 16942790
of course.. you have an empty if statement:
> if ($switcher == 1); {

just remove the ";"
0
 

Author Comment

by:BleuTango
ID: 16942823
LOL!
"It's so easy an idiot could do it... but there's never an idiot around when you need one. Bleu, get over here!"

Many thanks.
0
 
LVL 14

Expert Comment

by:ThG
ID: 16943158
you are welcome :-)
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

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.
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
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…

863 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now