Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

IF evaluation not outputting as expected

Posted on 2006-06-20
3
Medium Priority
?
222 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 2000 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
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…
Suggested Courses

971 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