Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Simple PHP question

Tags:

php

Yes, it's a simple question, but one that I can't find a answer for through the PHP documentation or Google. (I'm just learning PHP....)

If this works:

<?php $d=date("D"); if ($d="Mon") { ?>echo this text on Monday<?php endwhile; ?><?php } else { ?><?php } ?>

Why doesn't this?

<?php $d=date("D"); if ($d="Mon,Tue") { ?>echo this text on Monday and Tuesday<?php endwhile; ?><?php } else { ?><?php } ?>

Do I need different delimiters between Mon and Tue? I've tried || and && ....

Thanks, Mark

like image 514
markratledge Avatar asked Nov 29 '22 06:11

markratledge


1 Answers

You're performing an assignment of $d when you say ($d="Mon"). What you want is the comparison operator (==):

if ($d == "Mon" || $d == "Tue")
like image 141
John Rasch Avatar answered Dec 06 '22 09:12

John Rasch