Home > Backend Development > PHP Tutorial > Several ways to write what day of the week today is in PHP_PHP Tutorial

Several ways to write what day of the week today is in PHP_PHP Tutorial

WBOY
Release: 2016-07-21 16:13:09
Original
1169 people have browsed it

Copy code The code is as follows:

// The first way of writing
$da = date("w");
if( $da == "1" ){
echo "Today is Monday";
}else if( $da == "2" ){
echo "Today is Tuesday";
}else if( $da == "3" ){
echo "Today is Wednesday";
}else if( $da == "4" ){
echo "Today is Thursday" ;
}else if( $da == "5" ){
echo "Today is Friday";
}else if( $da == "6" ){
echo "Today is Friday" Saturday";
}else if( $da == "0" ){
echo "Today is Sunday";
}else{
echo "You made a mistake!!";
};
// The second way of writing
$ga = date("w");
switch( $ga ){
case 1: echo "Today is Monday";break;
case 2 : echo "Today is Tuesday";break;
case 3 : echo "Today is Wednesday";break;
case 4 : echo "Today is Thursday";break;
case 5 : echo "Today is Friday";break;
case 6 : echo "Today is Saturday";break;
case 0 : echo "Today is Sunday";break;
default : echo "You entered Wrong! ";
};
// The third way of writing

echo "Today is Sunday". mb_substr("日一二三四五六",date("w"), 1,"utf-8" );

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/313573.htmlTechArticleCopy the code The code is as follows: // The first way of writing $da = date("w"); if( $ da == "1" ){ echo "Today is Monday"; }else if( $da == "2" ){ echo "Today is Tuesday"; }else if( $da == "3"...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template