Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

IF evaluation not outputting as expected

Posted on 2006-06-20
3
Medium Priority
?
221 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
[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
  • 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: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone 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

I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
This article discusses how to create an extensible mechanism for linked drop downs.
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…

715 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